Subject: Re: Problems with ccd (960413)
To: Justin T. Gibbs <gibbs@freefall.freebsd.org>
From: Charles M. Hannum <mycroft@MIT.EDU>
List: current-users
Date: 05/15/1996 23:08:26
"Justin T. Gibbs" <gibbs@freefall.freebsd.org> writes:

> 
> >Additionally, the behaviour suggested in item 2 would require either
> >disallowing the start routine from ever sleeping (meaning that it
> >would always have to use SCSI_NOSLEEP), or adding an additional lock
> >to prevent another process entering the start routine (from the
> >strategy routine) and trying to start the same buffer.
> 
> Hmmm, yuck.  You could work around this by guarding against the
> queue being empty.  The only real restraint here is that the
> transactions are queued in the same order as the buffers (tape writes
> won't work otherwise), but you don't care if the buffer you pull off
> the queue is the same one that you looked at before you slept.

In the case where the adapter driver or mid-level code sleeps waiting
for memory, that's not applicable, because you're still operating on
the same buffer when you wake up.  In this case, since you haven't yet
dequeued the buffer (per Noriyuki's suggestion), there is a race
condition.  Since you never sleep directly from *start(), but only
from some lower-level code, I'm not sure what it is you're talking
about.