Ive looked at nanosleep() but I believe this puts the whole process to sleep
(All threads).
thanks for any help
Jim Shelton
: Ive looked at nanosleep() but I believe this puts the whole process to sleep
: (All threads).
wrong. nanosleep() only puts the calling thread to sleep. You need to
consider that your thread/process may often be context switched out by
the kernel and you can't guarentee that your thread will always run
every 50ms.
If you need to guarantee this, get a dead-line monotonic RTOS.
--
Cheers.
Well, as with anything on Unix (Linux), there are several ways to do this.
- wait for a duration (nanosleep/sleep/usleep)
- interval timers (setitimer/getitimer)
- busy wait, read the clock (gettimeofday)
Most of the timing benchmarks I've seen use nanosleep - I'm pretty sure that
can meet your need if coded carefully. Make sure you don't drift in the timing
routine, the errors tend to accumulate faster than you expect.
We have software that must run on a variety of platforms (development machines,
machines w/ IRIG-B time synchronization, etc.) so we tend to package the timing
stuff into a separate application & signal the real time task when its time to
wake up. That is a pretty heavy interface to support - I'd suggest one of the
other solutions based on what your needs are.
--Mark