[ntp:hackers] smearing the leap second

Warner Losh imp at bsdimp.com
Sat Jul 11 16:20:10 UTC 2015


> On Jul 11, 2015, at 2:32 AM, Hal Murray <hmurray at megapathdsl.net> wrote:
> 
> Getting TAI using the tai_offset via adjtimex() isn't trivial, at least if
> you expect your code to do the right thing when running over a leap second.
> You have to do something like:
>  read tai_offset
>  read time in UTC
>  read tai_offset again
> If the tai_offsets differ, you were reading the clock close to the leap
> second.  Try again.

Actually, that’s not entirely correct. There’s a lock that ensures that things
from ntpd are adjusted atomically in FreeBSD. So the TAI time scale can
be implemented with the adjustment since the adjustment doesn’t change
until the leap leaps and sets UTC back a second. So long as that operation
is atomic wrt updating tai_offset (which I believe the locks there today ensures),
then as long as you hold the locks (which you need to do to read the time)
you should be set.

But there’s been little call for a CLOCK_TAI in FreeBSD. And ntpd doesn’t
(or at least old versions didn’t) set tai_offset, so it would be a lie most of
the time anyway.

Warner

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.ntp.org/pipermail/hackers/attachments/20150711/e42bcd46/attachment.sig>


More information about the hackers mailing list