[ntp:questions] Re: Time set backward

David L. Mills mills at udel.edu
Fri Jan 6 21:24:27 UTC 2006


The ntpd daemon does not use Unix timers in any way except to implement 
a recurring one-second interrupt which defines process time. All other 
time values are based on either advancing or retarding the system clock 
by some amount. The two functions are kept ruthlessly separate and 
independent. Process time advances one second at a time whether or not 
the system time is set back one hour by some means separate from ntpd, 
but eventually ntpd will set it forward again.

I don't understand how POSIX can implement a time of day function using 
timers. Timers operate in process time or system uptime; there is no way 
to synchronize them to an arbitrary epoch determined from an external 


Brian Utterback wrote:
> David L. Mills wrote:
>> Sivakumar,
>> In the reference implementation that leaves here, packets are sent 
>> regardless of whether the time has been set forward or backward. In 
>> the kernel implementation that leaves here, time is always 
>> monotonically increasing except when explicitly set backward more than 
>> two seconds. This may not account for various modifications by folks 
>> after the code has left here.
> Right, and as the poster said, the clock was inadvertently set back
> a hour.
> This is an unfortunate side effect of the fact that POSIX timers are
> used both for strict interval timing and synchronized to a clock
> timing, and that POSIX is silent about what to do when the clock
> is set backwards.
> There is no clear "right thing" to do. If you are using interval
> timing, you will likely want one thing, and if you are using
> synchronized timing, then you will want the other.
> The ntpd daemon actually handles this by resetting the timers
> when it steps the clock backwards, but it is in a unique
> position to know about backwards steps, and then only when
> it does them itself.
> So, the only way for ntpd to proctect itself against this kind
> of problem is the time honored rule: Only ntpd may adjust the
> clock. Really, we mean it.

More information about the questions mailing list