Device driver subtleties

Brian Thomson thomson at uthub.UUCP
Tue Jul 31 05:31:10 AEST 1984


Dave Cohrs comments:
> > From:  Don Speck <speck at CIT-VAX.ARPA>
> > 
> >    When writing a device driver, what does it mean to call sleep() while
> > at ipl 0x14?  I'm using it like this:
> > rlpwrite(args) {
> > 	...
> > 	(void) spl4();	/* Lock out interrupts between test and sleep */
> > 	while (! flag_set_by_interrupt_routine) {
> > 	    sleep((caddr_t)lp->lp_buf, PZERO+8);
> > 	}
> > 	(void) spl0();
> 
> If you raise your priority like this, it will lock out *ALL* interrupts
> for all priorities <= spl4().  How is your 'flag_set_by_interrupt_routine'
> going to get set when the interrupt will never get received?

His comment is not correct.  The interrupt will be received,
because sleep() does an spl0() after arranging for the eventual wakeup()
call.  The spl4() call above is correct, for exactly the reason stated
in the comment that follows it:  the interrupt must not be permitted
to occur between testing the flag and performing the sleep().
-- 
		    Brian Thomson,	    CSRI Univ. of Toronto
		    {linus,ihnp4,uw-beaver,floyd,utzoo}!utcsrgv!uthub!thomson



More information about the Comp.unix.wizards mailing list