eggert at cs.ucla.edu
Fri Jul 1 17:08:23 UTC 2011
On 07/01/11 09:43, Guy Harris wrote:
> It also means that if your really want to know how many seconds
> elapse between two events, don't use POSIX time_t.
... or more precisely, don't use POSIX clock_gettime (CLOCK_REALTIME, ...).
POSIX apps are supposed to use clock_gettime (CLOCK_MONOTONIC, ...)
if they want to count elapsed time. This POSIX feature is
needed for reasons other than leap seconds, for example,
if your sysadmin (or NTP subsystem) changes the real-time
clock, CLOCK_MONOTONIC is supposed to be immune to that.
This is a tricky business, though, since NTP does adjust the
the clock *frequency*, and CLOCK_MONOTONIC is *not* supposed
to be immune to *that*. If you want your elapsed-time measurements
to be more reliable in the presence of clock-frequency adjustments,
you need something fancier, e.g., GNU/Linux's CLOCK_MONOTONIC_RAW.
More information about the tz