How to ensure monotonic nondecreasing time
Posted Nov 16, 2006 6:26 UTC (Thu) by
pjm (subscriber, #2080)
Parent article:
Counting on the time stamp counter
One way of guaranteeing that ‘time never goes backwards’ is to use a variant of Lamport timestamps (or see full paper). For gettimeofday, we have it a bit easier: gettimeofday gives only microsecond precision, so it only guarantees that time never goes backwards, it doesn't guarantee that time advances between two events. Thus, we don't even need the property that distinct events have distinct timestamps, so we don't need the process ID stuff mentioned on that page, and we could go so far as to ~gratuitously drop the “and then applies rule 1 before timestamping the event as received” part from rule 3.
[Dropping that part of rule 3 would more often expose callers mistakenly assuming that time strictly increases. Exposing bugs more often may be either a good or bad thing.]
(
Log in to post comments)