context switching during delays

Aaron J. Grier aaron at frye.com
Wed Jul 25 21:57:30 UTC 2001


On Wed, Jul 25, 2001 at 12:23:52PM -0400, Hennenfent, Nick {AVL~Roswell} wrote:

> On a more philosophical note, I need to do short delays in some of my
> device drivers.
> 
> Say 1/10 of a second.
> 
> What is the appropriate routine to use???
> Should I use a busy/spin loop or should I use something that context
> switches???
> 
> sleep()
> nanosleep()
> rtems_task_wake_after()
> Something else???

to start with, your options depend on how frequently the scheduler is
running.  the granularity of rtems_task_wake_after depends on how
frequently the scheduler runs.  obviously you won't be able to get a
100ms delay with rtems_task_wake_after if the scheduler is only running
every 500ms.

I believe with sufficient priority tuning, you could get accurate 100ms
delays out of rtems_task_wake_after with a short enough scheduler time.
(10ms, 20ms...)  another option to look at might be the rate monotonic
scheduler.

no better way to discover than to code it up and test it out!  :)

-- 
  Aaron J. Grier   |    Frye Electronics, Tigard, OR   |   aaron at frye.com
                       Of course unix clones exist...
                  How else are unix supposed to reproduce?



More information about the users mailing list