Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site uthub.UUCP Path: utzoo!utcsrgv!utai!uthub!thomson From: thomson@uthub.UUCP (Brian Thomson) Newsgroups: net.unix-wizards Subject: Re: Device driver subtleties Message-ID: <172@uthub.UUCP> Date: Mon, 30-Jul-84 15:31:10 EDT Article-I.D.: uthub.172 Posted: Mon Jul 30 15:31:10 1984 Date-Received: Mon, 30-Jul-84 18:57:55 EDT References: <336@sri-arpa.UUCP>, <356@uwvax.ARPA> Organization: CSRG, University of Toronto Lines: 25 Dave Cohrs comments: > > From: Don Speck> > > > 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