Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Sep 2004 19:22:49 -0700
From:      Nate Lawson <nate@root.org>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        "M. Warner Losh" <imp@bsdimp.com>
Subject:   Re: cvs commit: src/sys/dev/md md.c
Message-ID:  <414A4A79.8060101@root.org>
In-Reply-To: <200409162152.41670.jhb@FreeBSD.org>
References:  <20040916204321.GE30151@darkness.comp.waw.pl> <414A109E.4080601@samsco.org> <20040916.185915.35504747.imp@bsdimp.com> <200409162152.41670.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
John Baldwin wrote:
> On Thursday 16 September 2004 08:59 pm, M. Warner Losh wrote:
> 
>>In message: <414A109E.4080601@samsco.org>
>>
>>            Scott Long <scottl@samsco.org> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?414A4A79.8060101>