Hacker News new | ask | show | jobs
by calanya 3544 days ago
That the clock always moves forward.

As one example, some clocks are cpu specific (rather than system specific). When a thread gets scheduled to a different cpu, it might be talking to a different clock, and getting a backwards time.

The user might also be changing the clock while the program is running, of course.

If the forward direction of time is important, make sure the the source of time is a monotonic clock API.

1 comments

All I can add is a warning about running NTP if you are maintaining a priority queue of time-stamped actions (now + delta, where delta depends on the action): use CLOCK_MONOTONIC instead of wall time.