cvs commit: src/sys/dev/md md.c

Nate Lawson nate at root.org
Thu Sep 16 19:22:55 PDT 2004


John Baldwin wrote:
> On Thursday 16 September 2004 08:59 pm, M. Warner Losh wrote:
> 
>>In message: <414A109E.4080601 at samsco.org>
>>
>>            Scott Long <scottl at 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



More information about the cvs-src mailing list