News for hackers. Stuff that matters.
Re:gettimeofday() should never be used to measure time by hmpc on Monday January 19, 2015 @04:20AM (#8911099)
You can already do this in POSIX.1-2001-conforming systems like Linux using `clock_nanosleep` (http://man7.org/linux/man-pages/man2/clock_nanosleep.2.html).
Re:gettimeofday() should never be used to measure time by JoeAltmaier on Tuesday January 20, 2015 @06:21PM (#8920390)
Still just a Sleep(), right? So the latency in the callback can be added to the next time, with resulting drift. The idea is, I know when I want to be called back, as an actual number. I want a sleepuntil() that I pass the actual time.
Re:gettimeofday() should never be used to measure time by hmpc on Wednesday January 21, 2015 @11:30AM (#8923791)
Unless I misunderstood, that's what the TIMER_ABSTIME option is for. This is actually what I use for soft real-time loops, when I'm concerned about both drift and jitter.
Re:gettimeofday() should never be used to measure time by JoeAltmaier on Wednesday January 21, 2015 @10:50PM (#8927444)
Ok thanks, I reread it, that seems to be the case! I hope the seconds field is honored along with ns. WinCE had a bug where they used a long. If latency made your call for a small interval occur after the interval had elapsed, you slept for 19.5 minutes instead (nearly a full count). Combining the ns with a second counter should be enough bits to avoid that.