I have a piece of code roughly organized like this: clock_gettime(CLOCK_REALTIME, &start); elapsedSecs = 0; while (elapsedSecs < SAMPLE_TIME) { /* * Do some stuff */ usleep(10000); /* 10 ms delay */ clock_gettime(CLOCK_REALTIME, &now); elapsedSecs = now.tv_sec - start.tv_sec; }
Realizing that usleep() is not necessarily deterministic, I replaced the usleep() call with: delayStart = gethrtime(); while ((gethrtime() - delayStart) < SAMPLE_DELAY) ; What I find is that, after the call to gethrtime(), the variable "now" has the same values as the variable "start". resulting in elapsedSecs always being equal to 0. If I replace the gethrtime() version of the code with usleep(), it all works again. Is there some known interaction between clock_gettime() and gethrtime() that I might be unaware of? Thanks. Ken Ramey Steward Observatory -- [rtl] --- To unsubscribe: echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED] -- For more information on Real-Time Linux see: http://www.rtlinux.org/