Device driver subtleties

dave at uwvax.ARPA dave at uwvax.ARPA
Thu Jul 26 01:06:34 AEST 1984


> 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?  Methinks
you have process priority and device priority confused.  Also, your code
can do unexpected things.  A more correct way of handling the spl's is:

	spx = spl4();	/* save old priority and change to spl 4 */
	< critical section >
	(void) splx(spx);	/* restore priority to normal */

Now, back to your question.  The  sleep() will sleep at priority PZERO (normal)
plus 8.  This means it's interruptable by signals (which won't be sent
because you're at high priority, so noone else is going to run, except maybe
the clock).

-- 
Dave Cohrs @ wisconsin
...!{allegra,heurikon,ihnp4,seismo,ucbvax,uwm-evax}!uwvax!dave
dave at wisc-rsch.arpa



More information about the Comp.unix.wizards mailing list