Warning is not for me. I am not some "misguided lad". That would be YOUR interpretation of how ntpd actually works that is "misguided".syzygy wrote:Funny, the author put in a warning just for you.bob wrote:* Important note: The kernel discipline is used only if the
* step threshold is less than 0.5 s, as anything higher can
* lead to overflow problems. This might occur if some misguided
* lad set the step threshold to something ridiculous.
clock_gettime() with CLOCK_MONOTONIC guarantees that any discontinuities due to invocations of settimeofday() are ignored. It does exactly what you would want (unless you prefer to ignore adjtime() invocations as well in which case you need CLOCK_MONOTONIC_RAW).
"clock()" also gives you a monotonic "time" that is not a time. It measures pure CPU time which doesn't care about suspend/resume or anything else. Not worth much for doing things with real time however. You can even do your OWN clock if you want. Define a variable and increment it every so often. Wait. We have that. It is the node counter in a chess engine. But we have to play by a real clock, not a pseudo-clock.