From owner-cvs-src@FreeBSD.ORG Sun May 25 01:31:34 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B371837B404; Sun, 25 May 2003 01:31:34 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4A7C943F85; Sun, 25 May 2003 01:31:34 -0700 (PDT) (envelope-from mtm@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h4P8VY0U055710; Sun, 25 May 2003 01:31:34 -0700 (PDT) (envelope-from mtm@repoman.freebsd.org) Received: (from mtm@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h4P8VYgv055709; Sun, 25 May 2003 01:31:34 -0700 (PDT) Message-Id: <200305250831.h4P8VYgv055709@repoman.freebsd.org> From: Mike Makonnen Date: Sun, 25 May 2003 01:31:33 -0700 (PDT) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Subject: 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 X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 May 2003 08:31:35 -0000 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