From owner-cvs-src@FreeBSD.ORG Fri Sep 17 02:22:55 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 4128C16A4CE; Fri, 17 Sep 2004 02:22:55 +0000 (GMT) Received: from ylpvm15.prodigy.net (ylpvm15-ext.prodigy.net [207.115.57.46]) by mx1.FreeBSD.org (Postfix) with ESMTP id F29F943D46; Fri, 17 Sep 2004 02:22:54 +0000 (GMT) (envelope-from nate@root.org) Received: from [10.0.5.52] (adsl-64-171-186-250.dsl.snfc21.pacbell.net [64.171.186.250])i8H2Moej027632; Thu, 16 Sep 2004 22:22:50 -0400 Message-ID: <414A4A79.8060101@root.org> Date: Thu, 16 Sep 2004 19:22:49 -0700 From: Nate Lawson User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040901) X-Accept-Language: en-us, en MIME-Version: 1.0 To: John Baldwin References: <20040916204321.GE30151@darkness.comp.waw.pl> <414A109E.4080601@samsco.org> <20040916.185915.35504747.imp@bsdimp.com> <200409162152.41670.jhb@FreeBSD.org> In-Reply-To: <200409162152.41670.jhb@FreeBSD.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: scottl@samsco.org cc: src-committers@FreeBSD.org cc: pjd@FreeBSD.org cc: cvs-src@FreeBSD.org cc: cvs-all@FreeBSD.org cc: "M. Warner Losh" Subject: Re: cvs commit: src/sys/dev/md md.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: Fri, 17 Sep 2004 02:22:55 -0000 John Baldwin wrote: > 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. :) Isn't this exactly what I said? -Nate