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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.