Subject: Re: USB stack needs early review (Re: Someone should fix our USB stack...)
To: Reinoud Zandijk <reinoud@NetBSD.org>
From: SODA Noriyuki <soda@sra.co.jp>
List: tech-kern
Date: 05/29/2007 18:15:22
>>>>> On Tue, 29 May 2007 09:02:07 +0200,
      Reinoud Zandijk <reinoud@NetBSD.org> said:

> yes, i think the author meant:
>
> s = splfoo();
> while (!(sc->flags & SCF_INTERURUPTED)) {
> 	splx(s);
> 	tsleep(...);
> 	s = splfoo();
> }
> splx(s);

No.
The spl(x) before tsleep() and the splfoo() after tsleep() are both
redundant.

> 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?

Yes, you are wrong. ;-)
As you suppose, tsleep() modifies current priority level to allow
interrupts.  See the Xspllower call in sys/arch/i386/i386/locore.S,
of netbsd-4 branch, for example.
-- 
soda