Re:gettimeofday() should never be used to measure time
by JoeAltmaier on Tuesday January 20, 2015 @06:20PM
(#8920380)
Really hard things are what OS code is FOR. Get it right once; then apps call it and it works.
There's a lot of "what ifs" that need to be answered for something that seems so simple:
* What clock are you using? Machine ticks? Wall clock? Is it correct? Is it stable enough?
* What if the clock misses the time that I asked for? Do you run it anyway? Do you skip that invocation?
* What if the clock moves backwards? Will you trigger twice? Will you even notice?
* What if I have a leap second so there are 61 seconds in the hour? What if a second is removed so there are 59 seconds in the hour?
The reason why people don't touch this stuff or get it wrong is because it's really hard. There's a lot of corner cases when it comes to time handling.