LWN.net Logo

Leaping seconds and looping servers

Leaping seconds and looping servers

Posted Jul 3, 2012 22:07 UTC (Tue) by simlo (subscriber, #10866)
In reply to: Leaping seconds and looping servers by kunitz
Parent article: Leaping seconds and looping servers

Yes, if I would (if I had the time) do the following

Make a alias for the POSIX CLOCK_REALTIME -> CLOCK_UTC. Make a new CLOCK_TAI running along CLOCK_UTC. And some function to get the difference between CLOCK_TAC and CLOCK_UTC at any given time (except you don't know about future leap seconds).
Many POSIX API implicitly CLOCK_REALTIME=CLOCK_UTC. Alternativ APIs must be made where the user can choose between CLOCK_UTC, CLOCK_TAI, CLOCK_MONOTONIC etc. In many (most) cases CLOCK_MONOTONIC would make most sense.

In the applications I am working on right now, I would try to restrict myself to CLOCK_MONOTONIC and CLOCK_TAC, but I would need to translate to and from UTC because some protocols require timestamps in UTC.
Right now we are using CLOCK_REALTIME and using arithmetic on the resulting struct timestamp to find time differences.


(Log in to post comments)

Leaping seconds and looping servers

Posted Jul 3, 2012 23:43 UTC (Tue) by dashesy (subscriber, #74652) [Link]

This is what I use for any relative time:

#ifndef CLOCK_MONOTONIC_RAW
#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
#endif

Leaping seconds and looping servers

Posted Jul 4, 2012 13:57 UTC (Wed) by simlo (subscriber, #10866) [Link]

Use of CLOCK_MONOTONIC is not an option because we might want to compare timestampt between different servers.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds