[Coco] F$Sleep, drivers, and interrupt masks

Chuck Youse cyouse at serialtechnologies.com
Thu Sep 18 14:40:06 EDT 2008


On Thu, 2008-09-18 at 14:30 -0400, Chuck Youse wrote:
> On Thu, 2008-09-18 at 14:30 -0400, Chuck Youse wrote:
> > On Thu, 2008-09-18 at 12:17 -0600, L. Curtis Boyle wrote:
> > 
> > > I can't remember, but I think the Suspend bit (in Level 2, anyways) is  
> > > what one should use instead of F$Sleep. Hopefully somebody else remembers  
> > > better than I do.
> > 
> > Indeed, butya still gotta sleep after your set your suspend bit :)

Ok, poring over docs.  Now I see how it works and avoids the race
condition:

1. With interrupts disabled, set up V.WAKE, set your process suspend
bit, and issue the command to the device controller; re-enable
interrupts.
2. Give up the current timeslice with X=1 and F$Sleep; the process will
not be rescheduled until the suspend bit is cleared by the IRQ service
routine.

The whole point is that the race is non-existent because scheduling is
controlled by the suspend bit, which, if cleared by the IRQ service
routine before you hit F$Sleep, only results in a minor delay until
you're rescheduled.

Thanks Curtis for unrusting my brain bits.

C.
 




More information about the Coco mailing list