[chrony-dev] Wake from sleep on OS X

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


I set my machine to sleep (hibernate) after 30 minutes of inactivity (for whatever definition of activity used by Apple, but I guess its as simple as mouse/keyboard events, closing lid on laptop etc)

If chronyd is running as an NTP server then clearly the administrator/user would have disabled sleep events and the system would run continuously.

However, I think a common use case is to run chronyd as an ntp client, i.e using chronyd to keep the system clock as close to NTP as it can.

When the machine wakes up I see syslog messages such as:
Dec  1 00:00:28 number9 chronyd[3450]: Forward time jump detected!
Dec  1 00:00:52 number9 chronyd[3450]: System clock wrong by 5.978007 seconds, adjustment started
Dec  1 07:30:07 number9 chronyd[3450]: Forward time jump detected!
Dec  1 07:30:31 number9 chronyd[3450]: System clock wrong by 6.672551 seconds, adjustment started
Dec  1 08:10:13 number9 chronyd[3450]: Forward time jump detected!
Dec  1 08:10:37 number9 chronyd[3450]: System clock wrong by 6.625014 seconds, adjustment started

And then it can take a couple of minutes before the local offset converges to something less than a millisecond.

OS X has an API for getting notification of sleep/wake events so I was thinking of something like

1. Receive 'about to sleep' notification
	pause chronyd scheduler
	allow system to sleep

2. Receive 'has woken up' notification
	set T0 in the Mac driver to current gettimeofday()
	reinitialise drift correction interval to default
	any other book keeping chores required in the driver
	restart chronyd scheduler

I'm not sure of the best approach to pausing/restarting the scheduler. 

A new entry point that sets the state of the scheduler, then in SCH_MainLoop() poll the state at say 1 second intervals (doing nothing if in a sleeping state) would be one option

Maybe a callback to the driver from the scheduler that performs a waitloop if the system is asleep before returning. I think this option means minimal change to the scheduler itself.

What do you think about this?

-- 
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/