System clock always unsynced

Christian Weisgerber naddy at mips.inka.de
Tue Apr 28 11:57:47 UTC 2015


Ian Lepore:

> > Okay, let me rephrase this since the first two replies completely
> > missed the point.  This is an API programming question.  How is the
> > poorly documented ntp_adjtime() API to be used so the system clock
> > will lose the STA_UNSYNC status and switch from TIME_ERROR to TIME_OK
> > as clock state?
> 
> It requires a call to ntp_adjtime() with the MOD_STATUS bit set in
> ntv.modes and the STA_UNSYNC bit clear in ntv.status.

Well, yes.  You omitted the crucial piece of information, but I
think I have figured it out from reading kern_ntptime.c: The
STA_UNSYNC value is _read_ by the kernel and (mostly) _set_ by
userland.  It is ntpd that is supposed to clear STA_UNSYNC to signal
the kernel that the time is synchronized.

The ntp_adjtime(2) man page doesn't say anything how STA_UNSYNC is
used and I had naturally assumed that it was the kernel that cleared
STA_UNSYNC to let ntpd know (that the offsets had been applied or
whatever).

-- 
Christian "naddy" Weisgerber                          naddy at mips.inka.de


More information about the freebsd-hackers mailing list