Subject: Re: fast timeouts (< 1 millisecond)??
To: Chris G Demetriou <Chris_G_Demetriou@ux2.sp.cs.cmu.edu>
From: Matt Thomas <matt@lkg.dec.com>
List: tech-kern
Date: 11/14/1996 17:49:33
> > It would really be helpful to my driver if there was a mechanism to 
> > schedule quick timeouts (ie. much less than 1/hz and usually on the
> > order of 10s of microseconds)?
> > 
> > Currently, some of my driver spin for 1 millisecond (or less) and
> > I'd like to see the system do something other than reading a CSR
> > for that time.
> > 
> > Any comments?
> 
> Well, i suppose i've got a couple of questions, like:
> 
> 	(1) what would you have the system doing?

anything else that it has to < splsoftclock().  For some devices, it may
take several (variable amount) milliseconds before the condition passes.
Being able to poll every (500us, 1ms) would be useful.  Think of this
as high-speed software interrupts.

> 	(2) what method would you suggest for having the system figure
> 	    out when to stop delaying?

I assumed there would an interface similar to timeout()/untimeout()
but take an argument in nanoseconds instead of ticks.  The system could
then adjust the delay upward so its units.

For the alpha, one can use the cycle counter to generate fine grained
interrupts (by enabling the wraparound interrupt and setting the cycle
counter appropriately.

For the pentium pro, one can do similar things.  On ISA machines, one can
use the clock chip to get 10s of microsecond accuracy.  

It's definitely platform specific, so you'll need a way for a driver to
get the smallest interval that can get scheduled so it can decide to spin
or not.

> On many ports, it's hard to get finer-granularity timing than 'hz' to
> begin with...

true but it would be nice.

> While it is annoying to have to spin loop in drivers and waste cycles,
> i'd like to know what the alternatives could be...

My concern is also interrupt latency.  While the drivers spins (usually
at high SPL), the system stops taking interrupts.  
-- 
Matt Thomas               Internet:   matt@3am-software.com
3am Software Foundry      WWW URL:    http://www.3am-software.com/bio/matt.html
Westford, MA              Disclaimer: I disavow all knowledge of this message