cvs commit: src/lib/libthr/thread thr_exit.c thr_gc.c thr_info.c thr_init.c thr_join.c thr_private.h thr_stack.c

Mike Makonnen mtm at FreeBSD.org
Sun May 25 01:31:35 PDT 2003


mtm         2003/05/25 01:31:33 PDT

  FreeBSD src repository

  Modified files:
    lib/libthr/thread    thr_exit.c thr_gc.c thr_info.c thr_init.c 
                         thr_join.c thr_private.h thr_stack.c 
  Log:
  Start locking up the active and dead threads lists. The active threads
  list is protected by a spinlock_t, but the dead list uses a pthread_mutex
  because it is necessary to synchronize other threads with the garbage
  collector thread. Lock/Unlock macros are used so it's easier to make
  changes to the locks in the future.
  
  The 'dead thread list' lock is intended to replace the gc mutex.
  This doesn't have any practical ramifications. It simply makes it
  clearer what the purpose of the lock is. The gc will use this lock,
  instead of the gc mutex, to synchronize access to the dead list with
  other threads.
  
  Modify _pthread_exit() to use these two new locks instead of GIANT_LOCK,
  and also to properly lock and protect thread state changes,
  especially with respect to a joining thread.
  
  The gc thread was also re-arranged to be more organized and less nested.
  
  _pthread_join() was also modified to use the thread list locks. However,
  locking and unlocking here needs special care because a thread could find
  itself in a position where it's joining an exiting thread that is
  waiting on the dead list lock, which this thread (joiner) holds. If the
  joiner doesn't take care to lock *and* unlock in the same order they
  (the joiner and the joinee) could deadlock against each other.
  
  Approved by:    re/blanket libthr
  
  Revision  Changes    Path
  1.6       +26 -30    src/lib/libthr/thread/thr_exit.c
  1.4       +38 -54    src/lib/libthr/thread/thr_gc.c
  1.3       +2 -0      src/lib/libthr/thread/thr_info.c
  1.6       +1 -1      src/lib/libthr/thread/thr_init.c
  1.5       +34 -27    src/lib/libthr/thread/thr_join.c
  1.11      +29 -6     src/lib/libthr/thread/thr_private.h
  1.2       +5 -9      src/lib/libthr/thread/thr_stack.c


More information about the cvs-all mailing list