Monotonic Clocks
In Time Order Keeping
Computer systems have their own internal clocks, which may drift away from universal time. It’s possible for users to set the clock time manually, or to synchronise automatically using Network Time Protocol to time servers.
This means that the local time of the system clock may be reset from time to time.
If you’re using a timestamp to record when a message arrived, a later message could get an system timestamp earlier than a previous message if the clock is reset in between.
There are a few ways to deal with this:
- Don’t care – the sequence of message may not be that important for your application
- Care – the sequence of messages is critical, so record their sequence of arrival,
- Care , but don’t want a sequence number, use a monotonic clock to record the timestamp, and after a reboot, process only after the monotonic clock is in order.
For more information, read: