Changeset ea7890e7 in mainline for kernel/generic/include/proc


Ignore:
Timestamp:
2007-06-01T15:47:46Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
07be3c4
Parents:
ff3a34b
Message:

More efficient and simpler task termination.

Based on the assumption, that after its creation, only the task itself can create more threads for itself,
the last thread with userspace context to execute thread_exit() will perform futex and IPC cleanup. When
the task has no threads, it is destroyed. Both the cleanup and destruction is controlled by reference
counting.

As for userspace threads, even though there could be a global garbage collector for joining threads, it is
much simpler if the uinit thread detaches itself before switching to userspace.

task_kill() is now an idempotent operation. It just instructs the threads within a task to exit.

Change in the name of a thread state: Undead → JoinMe.

Location:
kernel/generic/include/proc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/proc/task.h

    rff3a34b rea7890e7  
    6565       
    6666        char *name;
    67         /** Pointer to the main thread. */
    68         struct thread *main_thread;
    6967        /** List of threads contained in this task. */
    7068        link_t th_head;
     
    7674        context_id_t context;   
    7775
    78         /** If this is true, new threads can become part of the task. */
    79         bool accept_new_threads;
    8076        /** Number of references (i.e. threads). */
    81         count_t refcount;       
     77        atomic_t refcount;
     78        /** Number of threads that haven't exited yet. */
     79        atomic_t lifecount;
    8280
    8381        /** Task capabilities. */
     
    123121extern cap_t cap_get(task_t *t);
    124122
    125 
    126123#ifndef task_create_arch
    127124extern void task_create_arch(task_t *t);
  • kernel/generic/include/proc/thread.h

    rff3a34b rea7890e7  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2001-2007 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    4141#include <cpu.h>
    4242#include <synch/rwlock.h>
     43#include <synch/spinlock.h>
    4344#include <adt/btree.h>
    4445#include <mm/slab.h>
     
    8182        /** After a thread calls thread_exit(), it is put into Exiting state. */
    8283        Exiting,
    83         /** Threads that were not detached but exited are in the Undead state. */
    84         Undead
     84        /** Threads that were not detached but exited are in the JoinMe state. */
     85        JoinMe
    8586} state_t;
    86 
    87 /** Join types. */
    88 typedef enum {
    89         None,
    90         TaskClnp,       /**< The thread will be joined by ktaskclnp thread. */
    91         TaskGC          /**< The thread will be joined by ktaskgc thread. */
    92 } thread_join_type_t;
    9387
    9488/** Thread structure. There is one per thread. */
     
    153147        bool interrupted;                       
    154148       
    155         /** Who joinins the thread. */
    156         thread_join_type_t join_type;
    157149        /** If true, thread_join_timeout() cannot be used on this thread. */
    158150        bool detached;
    159151        /** Waitq for thread_join_timeout(). */
    160152        waitq_t join_wq;
     153        /** Link used in the joiner_head list. */
     154        link_t joiner_link;
    161155
    162156        fpu_context_t *saved_fpu_context;
Note: See TracChangeset for help on using the changeset viewer.