From owner-cvs-all@FreeBSD.ORG Mon May 12 03:48:03 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 15C7F37B401; Mon, 12 May 2003 03:48:03 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B3CE43FB1; Mon, 12 May 2003 03:48:02 -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 h4CAm20U081217; Mon, 12 May 2003 03:48:02 -0700 (PDT) (envelope-from mtm@repoman.freebsd.org) Received: (from mtm@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h4CAm2KP081216; Mon, 12 May 2003 03:48:02 -0700 (PDT) Message-Id: <200305121048.h4CAm2KP081216@repoman.freebsd.org> From: Mike Makonnen Date: Mon, 12 May 2003 03:48:02 -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_kern.c thr_mutex.c thr_private.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 May 2003 10:48:03 -0000 mtm 2003/05/12 03:48:02 PDT FreeBSD src repository Modified files: lib/libthr/thread thr_kern.c thr_mutex.c thr_private.h Log: Forced commit, for previous revision. Make state transitions of a thread on a mutex queue atomic (with respect to other threads and signal handlers). This includes: o Introduce two functions to implement atomicity with respect to other threads and signal handlers. Basically, _thread_critical_enter() locks the calling thread and blocks signals. _thread_critical_exit() unblocks signals and unlocks the thread. o Introduce two new functions: get_muncontested() locks a mutex that is not owned by another thread. get_mcontested() places a thread on a contested mutex's queue, taking care to use the _thread_critical_enter/exit functions to protect thread state. o Modify mutex_unlock_common() to also protect state transitions. In this case it needs the cooperation of mutex_queue_deq(), which must return with the thread locked and signals disabled *before* it takes the thread off the queue. Combine _pthread_mutex_lock() and _pthread_mutex_trylock() into one function: mutex_lock_common(), that can handle both cases. Its behaviour is controlled by an argument, int nonblock, which if not zero means do not attempt to acquire a contested mutex if the uncontested case fails. BTW, when I write about contested and uncontested mutexes, I'm writing about it from the application's point of view. I'm not writing about internal locking of pthread_mutex->lock, which is achieved differently. While internal mutex locking is mostly done, there's still a bit more work left in this area. Approved by: markm/mentor, re/blanket libthr Reviewed by: jeff (slightly diff. revision) Revision Changes Path 1.5 +0 -0 src/lib/libthr/thread/thr_kern.c 1.6 +0 -0 src/lib/libthr/thread/thr_mutex.c 1.6 +0 -0 src/lib/libthr/thread/thr_private.h