DragonFly commits List (threaded) for 2007-03
DragonFly BSD
DragonFly commits List (threaded) for 2007-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cvs commit: src/sys/kern kern_sig.c kern_synch.c src/sys/sys proc.h src/sys/vfs/procfs procfs_ctl.c


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Mar 2007 09:49:46 -0700 (PDT)

:...
:  Now we count all sleeping threads as stopped and also set LWP_WSTOP to
:  indicate so.  These threads will stop before return to userland.
:  Running threads (including the current one) will eventually stop when
:  returning to userland and will increase p_nstopped.  The last thread
:  stopping will then send a signal to the parent process.
:  
:  Discussed-with:  Thomas E. Spanjaard <tgen@netphreax.net>

    Also note that there is code somewhere to handle deep races in the
    actual descheduling of the thread itself.  Please make sure those
    race checks remain intact.

    It comes down to the TDF_RUNNING flag in the thread structure.  This
    flag is adjusted by the thread switch code in platform/pc32/i386/swtch.s,
    e.g. on line 300.  It's very simple... the TDF_RUNNING flag for the
    previously running thread is not cleared until AFTER the switch code
    has switched to the next running thread's stack.  The ordering is
    significant because most other process related flags are set BEFORE the
    actual exiting process deschedules itself, and thus create a race
    condition and are not suitable to determine when the related structures
    can be deallocated.

    The main check is in kern/kern_exit.c line 500 or so, TDF_RUNNING
    (and other flags) are checked to ensure that there is no race between
    the actual descheduling of the thread and exit1()'s reclamation of the
    resources.

    It is pretty well documented in-code but something I just wanted to
    bring your attention to since you are working on the exit code.

						-Matt




[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]