From owner-cvs-all@FreeBSD.ORG Fri Sep 17 01:53:41 2004 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 7482916A4EE for ; Fri, 17 Sep 2004 01:53:41 +0000 (GMT) Received: from mail2.speakeasy.net (mail2.speakeasy.net [216.254.0.202]) by mx1.FreeBSD.org (Postfix) with ESMTP id D92BE43D55 for ; Fri, 17 Sep 2004 01:53:40 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: (qmail 25079 invoked from network); 17 Sep 2004 01:53:40 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 17 Sep 2004 01:53:39 -0000 Received: from slimer.baldwin.cx (slimer.baldwin.cx [192.168.0.16]) (authenticated bits=0) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id i8H1rNN6002471; Thu, 16 Sep 2004 21:53:37 -0400 (EDT) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: "M. Warner Losh" Date: Thu, 16 Sep 2004 21:52:41 -0400 User-Agent: KMail/1.6.2 References: <20040916204321.GE30151@darkness.comp.waw.pl> <414A109E.4080601@samsco.org> <20040916.185915.35504747.imp@bsdimp.com> In-Reply-To: <20040916.185915.35504747.imp@bsdimp.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409162152.41670.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: scottl@samsco.org cc: src-committers@FreeBSD.org cc: pjd@FreeBSD.org cc: cvs-src@FreeBSD.org cc: cvs-all@FreeBSD.org cc: nate@root.org Subject: Re: cvs commit: src/sys/dev/md md.c 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: Fri, 17 Sep 2004 01:53:42 -0000 On Thursday 16 September 2004 08:59 pm, M. Warner Losh wrote: > In message: <414A109E.4080601@samsco.org> > > Scott Long writes: > : Or just use a semaphore. > > Or a condition variable. That doesn't help, a condition variable doesn't have state like a semaphore. The correct fix is to do this: thread A ---------- mtx_lock(); adjust_state(); mtx_unlock(); wakeup(); thread B --------- mtx_lock(); while (state_still_needs_sleep()) msleep(...) mtx_unlock() Proving that there is no race is left as an exercise to the reader. :) -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org