Re: [chrony-dev] Wake from sleep on OS X

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


> On 2/12/2015, at 1:22 AM, Miroslav Lichvar <mlichvar@xxxxxxxxxx> wrote:
> 
> On Tue, Dec 01, 2015 at 10:37:49PM +1300, Bryan Christianson wrote:
>> I am not sure what mechanisms are used when the kernel sleeps. I would expect the RTC to have been updated but maybe it isn't. Apple docs don't seem to cover this very well. I've been unable to find anything equivalent to hwclock to do the RTC update.
> 
> Maybe it's something ntpd or pacemaker normally do?

pacemaker is no longer used - I think that was a one time experiment, although Apple ntpd will still use it if it is configured on the system. The binary is no longer present.

>> 
>> When chronyd wakes from sleep, won't it see the abrupt change in time as a step and start compensating for that? 
> 
> If the RTC was set to the system time before suspend, it didn't drift,
> and its reading on resume was accurate, there would be no step in the
> offset, only the absolute time would jump and chronyd could in most
> cases go on as nothing happened.
> 
> But that's probably never the case. When a time jump is detected, the
> assumption is that something was messing with the clock or the system
> was suspended and the clock was reset from RTC. Old measurements are
> thrown away, associations are reset and chronyd starts from scratch.
> It needs 3 new measurements before it can start correcting the clock
> again.

I just checked Apples patched version of ntp (from OSX 10.10)

They detect sleep/wakeup events via a signal handler. At each iteration of their event loop they check for either sleep or wakeup events. Sleep events are ignored and wakeup events go through a similar restart process that you describe, stepping the time if required.

Maybe the log message in chrony could indicate that the step is as a result of the wakeup event. Or we could just leave it as is.

As for keeping the RTC clock in sync, ntpd appears to do this by calling settimeofday() each time it updates its stats files.

I can add a scheduled event in the Mac OS X driver to call settimeofday() at regular intervals to force the RTC update. I would think an update every 15 minutes would not be too expensive.

-- 
Bryan Christianson
bryan@xxxxxxxxxxxxx




--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/