Email list hosting service & mailing list manager

POSIX monotonic time Lassi Kortela (26 Jul 2020 20:27 UTC)
Re: POSIX monotonic time Lassi Kortela (26 Jul 2020 20:40 UTC)

POSIX monotonic time Lassi Kortela 26 Jul 2020 20:27 UTC

 From the SRFI:

"(monotonic-time)     →   timespec       (procedure)
POSIX clock_gettime()
The same as posix-time, except that the epoch is arbitrary. This epoch
cannot change after the current program begins to run. It is guaranteed
that a call to monotonic-time cannot return a time earlier than a
previous call to monotonic-time. This is not guaranteed for posix-time
because the system's POSIX clock is sometimes turned either forward or
backward."

While monotonic time is a very useful concept in general, I would like
to suggest removing this procedure from SRFI 170 in particular unless
there is a sound argument for keeping it. My reasoning is as follows:

- the epoch is arbitrary
- hence the timestamp cannot be reliably converted to UTC or TAI
- hence the main value of a timespec object is lost and the procedure
should just return an integer
- the precision/accuracy is arbitrary as well, further reducing the
usefulness of the procedure

On a related note, I can't make sense of the POSIX definitions from
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html>:

3.391 System Clock
A clock with at least one second resolution that contains seconds since
the Epoch.

3.313 Real Time
Time measured as total units elapsed by the system clock without regard
to which thread is executing.

3.228 Monotonic Clock
A clock measuring real time, whose value cannot be set via
clock_settime() and which cannot have negative clock jumps.