|[chrony-dev] Wake from sleep on OS X|
[ Thread Index |
| More chrony.tuxfamily.org/chrony-dev Archives
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] Wake from sleep on OS X
- From: Bryan Christianson <bryan@xxxxxxxxxxxxx>
- Date: Tue, 1 Dec 2015 11:14:51 +1300
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpcorp.com; s=a0-2; h=Feedback-ID:X-Smtpcorp-Track:To:Date:Message-Id: Subject:From; bh=dCXRs80n3Z2SHkdnWyu4NktogkPVI4N5633ZF90pNyw=; b=UwzxvaeYpwsl XZukyVvr38Y4OYb6nIefQLuG6vCJG/thlXvtKzGn4rrk7GfKw0xo9BuPo2m3loit/iXHRti5atzWz qSZnBVI+N4obxCH3PhkqalhCiUocuLbWf1JL8i3fLljB6O12DbDU4IPXR0VtAWjp5yCZW2SIbKpfB waoKhhrA9KPFKyN+AP9JrnW2KAjclyQkM+Mx8EunHvZmWzFCQsMgrkRBLFiPD1bJLT5nulDdlHWeL WKT8lJZrpNA6HvD6PpxUwze81dejju49DDeW2ZJFL7jRpmfl1kCru6XfDO+hNtMGS1jjldczIvPB4 /QlQOLexisB/LcFwCXEmOw==;
- Feedback-id: 149811m:149811acx33YQ:149811sLrdTAu7Cd:SMTPCORP
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: Forward time jump detected!
Dec 1 00:00:52 number9 chronyd: System clock wrong by 5.978007 seconds, adjustment started
Dec 1 07:30:07 number9 chronyd: Forward time jump detected!
Dec 1 07:30:31 number9 chronyd: System clock wrong by 6.672551 seconds, adjustment started
Dec 1 08:10:13 number9 chronyd: Forward time jump detected!
Dec 1 08:10:37 number9 chronyd: 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?
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.