Subject: Re: USB stack needs early review (Re: Someone should fix our USB stack...)
To: Andrew Doran <ad@netbsd.org>
From: Reinoud Zandijk <reinoud@netbsd.org>
List: tech-kern
Date: 05/29/2007 09:02:07
--eJnRUKwClWJh1Khz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sat, Apr 28, 2007 at 04:37:31PM +0100, Andrew Doran wrote:
> > > That code is simply bogus; it needs to look more like this:
> > >
> > > s = splfoo()
> > >   while (! (sc->flags & SCF_INTERRUPTED)) {
> > >         tsleep();
> > >   }
> > > splx(s);

yes, i think the author meant:

s = splfoo();
while (!(sc->flags & SCF_INTERURUPTED)) {
	splx(s);
	tsleep(...);
	s = splfoo();
}
splx(s);

How would otherwise the interrupt handler be able to enter the spl 
level/interrupt level needed to modify the value's :-) Or am i wrong in 
this and is tsleep() taking care of that in this situation?

> If you are targeting -current:
> 
> 	mutex_enter(&foo_lock);
> 	while ((sc->flags & SCF_INTERRUPTED) == 0)
> 		cv_wait(&foo_cv, &foo_lock);
> 	mutex_exit(&foo_lock);
> 
> :-)

Thats a lot better indeed! A lot cleaner too....

Just my $0.02,

Cheers,
Reinoud

--eJnRUKwClWJh1Khz
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (NetBSD)

iQEVAwUBRlvP54KcNwBDyKpoAQKLuQgAh29dsSwR3XVRnC3AtKyVkDENN4da1jgR
nG2pWEFKYF/5LxoKvxdPckNaWggXEGH0Tg6nKeTVmvFD3Jy1oHNSfkhwNdzp4haO
eIImdfTMOMv6w31y/L3DPc6CC2kefAB2dPcmbU+2ShIMI7c9MlTnP4jt0zDb7mbK
AmsgFNz2P1DZL1ZKBVUyT1NGcmW0hsX1x1QzSzegEPU75csWQD3g6lwAMHByP6XP
0UgcRzx50t9F8/IIxE1i5VMbTUhqdkweKJpNoSaCj6Q//I9rUlCeG1H6VocvS+El
3Jx8rL5YdWeewhU3x+pUEB83NyHvdtiORg3PdagvMaT/YoHY23vttQ==
=lBwN
-----END PGP SIGNATURE-----

--eJnRUKwClWJh1Khz--