My application would like to wake up 40 times a second and do some work. While
I don't really need hard real time, I'd don't want a lot of drift, either.
On WinCE, which I'm more used to, the Sleep() call is accurate to 1ms, so it's
not difficult to figure out how many ms away the next multiple of 25ms is, and
sleep for just that many ms. I usually only have 1-3ms of work to do in any
given cycle, so usually I'm passing 24 or 22 to Sleep(). It works reasonably
well.
But the scheduler tick on Linux isn't generally 1ms - it sounds like 10ms is
common. At 10ms, I'm worried that if I tell nanosleep() to nap for 23ms, it
will only wake up after 30ms, and that's much too big a wobble.
What's the preferred technique to get reasonably precise (to the ms) wakeups in
Linux? And, am I going to need to rebuild the kernel to change the HZ setting?
Note: I'm not excessively worried about efficiency. If I have to rebuild the
kernel to set HZ to 1000, I won't be overjoyed, especially if it turns out that
rebuilding the kernel is a big deal, but my app doesn't need a lot of CPU, so
losing some CPU to fast ticking is acceptable.
Note - I'm planning to use FIFO scheduling at a high priority, 98 or so, for
this thread.
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|