From owner-cvs-src@FreeBSD.ORG Tue Apr 6 12:19:04 2004 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 75B4016A4CE; Tue, 6 Apr 2004 12:19:04 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6F6D243D3F; Tue, 6 Apr 2004 12:19:04 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i36JHlGe036984; Tue, 6 Apr 2004 12:17:47 -0700 (PDT) (envelope-from jhb@repoman.freebsd.org) Received: (from jhb@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i36JHlTU036983; Tue, 6 Apr 2004 12:17:47 -0700 (PDT) (envelope-from jhb) Message-Id: <200404061917.i36JHlTU036983@repoman.freebsd.org> From: John Baldwin Date: Tue, 6 Apr 2004 12:17:47 -0700 (PDT) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/sys/kern kern_condvar.c src/sys/sys condvar.h 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: Tue, 06 Apr 2004 19:19:04 -0000 jhb 2004/04/06 12:17:46 PDT FreeBSD src repository Modified files: sys/kern kern_condvar.c sys/sys condvar.h Log: Associate a simple count of waiters with each condition variable. The count is protected by the mutex that protects the condition, so the count does not require any extra locking or atomic operations. It serves as an optimization to avoid calling into the sleepqueue code at all if there are no waiters. Note that the count can get temporarily out of sync when threads sleeping on a condition variable time out or are aborted. However, it doesn't hurt to call the sleepqueue code for either a signal or a broadcast when there are no waiters, and the count is never out of sync in the opposite direction unless we have more than INT_MAX sleeping threads. Revision Changes Path 1.48 +13 -2 src/sys/kern/kern_condvar.c 1.11 +5 -1 src/sys/sys/condvar.h