From owner-cvs-all@FreeBSD.ORG Thu Jul 17 06:39:54 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 6609037B408 for ; Thu, 17 Jul 2003 06:39:54 -0700 (PDT) Received: from mail.speakeasy.net (mail11.speakeasy.net [216.254.0.211]) by mx1.FreeBSD.org (Postfix) with ESMTP id 92D9643FAF for ; Thu, 17 Jul 2003 06:39:51 -0700 (PDT) (envelope-from john@baldwin.cx) Received: (qmail 17791 invoked from network); 17 Jul 2003 13:39:50 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender )encrypted SMTP for ; 17 Jul 2003 13:39:50 -0000 Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) by server.baldwin.cx (8.12.9/8.12.9) with ESMTP id h6HDdnGI025675; Thu, 17 Jul 2003 09:39:49 -0400 (EDT) (envelope-from john@baldwin.cx) Received: from zion.baldwin.cx (localhost [127.0.0.1]) by zion.baldwin.cx (8.12.9/8.12.9) with ESMTP id h6HDdnPg076440; Thu, 17 Jul 2003 09:39:49 -0400 (EDT) (envelope-from john@zion.baldwin.cx) Received: from localhost (localhost [[UNIX: localhost]]) by zion.baldwin.cx (8.12.9/8.12.9/Submit) id h6HDdne2076439; Thu, 17 Jul 2003 09:39:49 -0400 (EDT) From: John Baldwin To: Mike Makonnen Date: Thu, 17 Jul 2003 09:12:30 -0400 User-Agent: KMail/1.5 References: <200307171106.h6HB6emd076862@repoman.freebsd.org> In-Reply-To: <200307171106.h6HB6emd076862@repoman.freebsd.org> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200307170911.43767.jhb@FreeBSD.org> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_umtx.c src/sys/sys proc.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: Thu, 17 Jul 2003 13:39:54 -0000 On Thursday 17 July 2003 07:06 am, Mike Makonnen wrote: > mtm 2003/07/17 04:06:40 PDT > > FreeBSD src repository > > Modified files: > sys/kern kern_umtx.c > sys/sys proc.h > Log: > Fix umtx locking, for libthr, in the kernel. > ... > 2. Once a umtx was contested all future locks and unlocks > were happening in the kernel, regardless of whether it > was contested or not. To prevent this from happening, > when a thread locks a umtx it checks the queue for that > umtx and unsets the contested bit if there are no other > threads waiting on it. Again, this is slightly more > complicated than it needs to be because we can't hold > a lock across casuptr(). So, the thread has to check > the queue again after unseting the bit, and reset the > contested bit if it finds that another thread has put > itself on the queue in the mean time. > ... The in-kernel mutexes handle this case during the unlock routine. When unlocking a contested mutex, if there is only one waiter, we wake up that waiter and set the lock cookie to MTX_UNOWNED without the contested bit set. If the woken thread is the only thread to try to acquire the lock, it suceeds and the lock remains uncontested until another thread blocks trying to lock it. This would mean that the next lock of the lock would not need to bounce into the kernel if the lock was not owned by anyone. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/