3 ms·
I wrote a blog post about clocks and timers earlier: http://www.club.cc.cmu.edu/~cmccabe/blog_time_and_time_again.html http://www.club.cc.cmu.edu/~cmccabe/blog_
by cmccabe 13y ago
I wrote a blog post about clocks and timers earlier: http://www.club.cc.cmu.edu/~cmccabe/blog_time_and_time_again.html http://www.club.cc.cmu.edu/~cmccabe/blog_time_and_time_again...
It gets especially interesting when you start thinking about mutexes and condition variables with timeouts.
- Scramblejams 13y agoThis looks like an answer to my question I posted elsewhere under this story. (Namely, how do I get egg-timer elapsed time since a certain UTC time? Which, the UTC component isn't a must have for me, the Unix Epoch will work just as well.) But I notice that your solution is POSIX only. How about Windows? And how do NTP adjustments affect this solution -- surely when the NTP server tells you your system clock is consistently off by 16%, there's got to be some effect on clock_gettime with CLOCK_MONOTONIC, right? I'd like to retain the ability to use NTP to improve the accuracy of the results.
- cmccabe 13y agoCLOCK_MONOTONIC is affected by NTP on Linux, at least. UNIX time is not actually seconds since the epoch. It's just something very, very close. There are a few cases where the same time_t value repeats for two seconds in order to insert a leap second. With regard to Windows, I assume there are equivalents to all these interfaces, but I don't know what they are.