Originally Posted by
rasta_freak
Sorry for maybe offtopic question, but matsp, do you know maybe if there's a better way for high-precision timing than gettimeofday() (talking about Linux)? I mean, suppose I want thread to run exactly every 20 msec (and it's running for about 0.1-1.0 msecs), but i also want it to sleep() in between. I tryed signals (setitimer()) but they are pretty unprecise. Right now this thread is given SCHED_FIFO, static priority 1, and it does nanosleep() of 0.5 msec, and doing gettimeofday() + "calc_diff()" after every sleep. Is there a better way? (Sleeping at once gives more "offset"). And sorry once more if this is offtopic.
EDIT: oh yes, i raised HZ to 1000.