[ntp:questions] once 'ntpd' stops, does the drift file value continue to get used for clock adjustments?
Dave Hart
davehart at gmail.com
Fri Mar 18 13:45:14 UTC 2011
On Fri, Mar 18, 2011 at 8:38 AM, Martin Burnicki
<martin.burnicki at meinberg.de> wrote:
> David Woolley wrote:
>> Windows will probably retain the last correction, but this may include a
>> high frequency component.
>
> AFAIK the Windows port of ntpd restores the standard tick value when it
> terminates, so the drift compensation isn't in effect anymore thereafter.
I believe that was the case for 4.2.4. With 4.2.6 and later, the last
correction is left in place unless you happen to stop ntpd just after
a leap second. You can see evidence (in unfamiliar units) in the log
at ntpd restart:
7 Mar 07:56:48 ntpd[4196]: Clock interrupt period 15.600 msec (startup
slew 18.9 usec/period)
Here's the code. Note the function name is misleading, it is called
at ntpd shutdown similarly to how init_winnt_time() is called during
startup:
void
reset_winnt_time(void)
{
SYSTEMTIME st;
/*
* If we're in the 2-second slew right after a leap second,
* we don't want to continue that extreme slew, in that case
* disable our slewing and return clock discipline to the
* kernel. Similarly if we are not yet synchronized,
* our current slew may not be a good ongoing trim.
* Otherwise, our leave in place the last SetSystemTimeAdjustment
* as an ongoing frequency correction, better than nothing.
* TODO:
* Verify this will not call SetSystemTimeAdjustment if
* ntpd is running in ntpdate mode.
*/
if (sys_leap == LEAP_NOTINSYNC || ls_time_adjustment)
SetSystemTimeAdjustment(0, TRUE);
/*
* Read the current system time, and write it back to
* force CMOS update, only if we are exiting because
* the computer is shutting down and we are already
* synchronized.
*/
if (ntservice_systemisshuttingdown() && sys_leap != LEAP_NOTINSYNC) {
GetSystemTime(&st);
SetSystemTime(&st);
NLOG(NLOG_SYSEVENT | NLOG_CLOCKINFO)
msyslog(LOG_NOTICE, "system is shutting down, CMOS time reset.");
}
}
Cheers,
Dave Hart
More information about the questions
mailing list