Re: newbie delay/sleep question



Aaron Isotton <aaron@xxxxxxxxxxx> writes:

cstahl3 wrote:
I am developing a device driver that handles an interrupt. When my
device driver receives the interrupt I would like to sleep for 100
microseconds and then do some other task. My problem is I may receive
another interrupt within that 100 microseconds and the sleep I've been
trying to do is blocking the next guy from executing on time (waiting
for the first guy to finish sleeping).

I've been looking at using timers, task queues, and work queues, but
I'm not exactly sure if that's the way to go and it seems if I base my
delay on jiffies, I will not be able to satisfy my microsecond sleep
requirement. Any ideas?

Jiffies are increased at every tick (kernel tick, not clock tick), so
you usually get between 0.001 and 0.0001s granularity, depending on your
kernel configuration.

The most accurate clock source you can get is usually the TSC (rdtsc and
friends). But beware of CPUs with broken TSCs (such as some Geodes).

This is probably a bad advise for the following reasons (excluding the
fact that it might be broken and there's hardly a way to detect that):
a. RDTSC is architecture specific
[And even on IA32 it's subject to TSD restrictions in ring3]
b. Reports clock elapsed, and you might need to figure out how that
translates to something more meaningful (like seconds)
c. In my experience is not reliable on SMP

Also see: http://en.wikipedia.org/wiki/RDTSC

--
vale
.



Relevant Pages

  • Re: Premature wakeup of time.sleep()
    ... >> clock, shich varies from os to os. ... Once you have a wakeup time, you can put your sleeper in a time-ordered queue, ... have the option of a hot return as if the sleep call hadn't happened. ... meaning any time there is any interrupt. ...
    (comp.lang.python)
  • Re: newbie delay/sleep question
    ... microseconds and then do some other task. ... another interrupt within that 100 microseconds and the sleep I've been ... receive the interrupt and queue them up on a tasklet or work/wait queue ...
    (comp.os.linux.development.system)
  • Re: newbie delay/sleep question
    ... microseconds and then do some other task. ... another interrupt within that 100 microseconds and the sleep I've been ... Jiffies are increased at every tick, so ...
    (comp.os.linux.development.system)
  • newbie delay/sleep question
    ... I am developing a device driver that handles an interrupt. ... microseconds and then do some other task. ... another interrupt within that 100 microseconds and the sleep I've been ...
    (comp.os.linux.development.system)
  • Re: newbie delay/sleep question
    ... microseconds and then do some other task. ... another interrupt within that 100 microseconds and the sleep I've been ... Jiffies are increased at every tick (kernel tick, not clock tick), so ...
    (comp.os.linux.development.system)