#3359 NORM First D: Time server for XOs.
Zarro Boogs per Child
bugtracker at laptop.org
Sat Oct 20 07:14:04 EDT 2007
#3359: Time server for XOs.
----------------------------+-----------------------------------------------
Reporter: cscott | Owner: wad
Type: task | Status: new
Priority: normal | Milestone: First Deployment, V1.0
Component: school server | Version:
Resolution: | Keywords:
Verified: 0 |
----------------------------+-----------------------------------------------
Comment(by gnu):
Is the essence of the problem that the kernel copies the RTC into its idea
of the time, but the RTC only has 1-second resolution? If that's it,
there's a pretty good fix:
It should be possible to set the kernel clock accurately, by watching the
realtime clock tick to another second. This could even be done
incrementally, second by second, sneaking up on the instant that it ticks.
(Gen-2 should use a realtime clock with a counter and alarm that ticks off
much smaller units.)
So on wakeup, you set the time to the RTC time and 0 microseconds (say
04:06:05.0000. Set an RTC alarm to occur at the next second (04:06:06);
you'll get an interrupt right after it ticks. Your kernel time will be
maybe 04:06:05.314000. Now you know that time was too conservative; so
bump forward your idea of what time it is to be 04:06:06.00000. You're
almost synchronized with the tick, but you had some interrupt latency, so
you're still a little slow. Set an internal timer to wake you up 99% of
the way through the next second (at 04:06:06.99000), and when you get that
interrupt, sit in a tight loop and watch it tick over to 04:06:07.
Advance your internal clock to 04:06:07.00000 right then, and you'll be
accurate to within the time it takes to do one cycle of a tight loop
reading the RTC. In less than three seconds, you've probably recovered
the time "lost" in suspend -- and without ever making the clock run
backward. Think of this as adjtime for suspended clocks.
Then you won't need NTP to sync it to somewhere else. (Of course, this
kind of clock fiddling will give NTP some concern about the stability of
your local oscillator. Check in with Dave Mills, truechimer wizard, for
how to make this work best.)
--
Ticket URL: <https://dev.laptop.org/ticket/3359#comment:3>
One Laptop Per Child <https://dev.laptop.org>
OLPC bug tracking system
More information about the Bugs
mailing list