Salut, On Tuesday, September 25, 2007 at 18:23:54 +0200, Spoon wrote:
> systohw reads the current system time, then sleeps until the next > whole second, then writes that date to the RTC. Not good: systohw should sleep until a second and a half, then write the (old) plain second to the RTC. Half a second later, the RTC will update to the next second, and start ticking at 1 Hz. Not exactly half a second: The first tick (UIP fall and interrupt) comes roughly 502 milliseconds after oscillator restart, which is the last step of ioctl(RTC_SET_TIME) operations. The exact delay depends on the machine, is of course affected by the usual drift during half a second (typically up to some tens of microseconds), and is additionally affected by some quite important dispersion (typical range of a few hundreds of µs). The exact width of this dispersion range also depends on the machine. Note that the error and dispersion when *reading* the RTC is way lower than when writing. This permits an interesting feedback scheme, where you measure the error just after writing, and negate it when later reading. This scheme is implemented in the latest hwclock 2.30 from Bryan Henderson, and gives incredibly good results. Like writing then reading the time with a mean offset of 0 µs +-10. For comparision the older hwclock from util-linux-ng 2.13 gave results like mean offset -2500 µs +-170. And the ugly eleven minutes mode in a synced kernel gives a mean offset of -2150 µs +-5000 (!!). > it seems like the RTC raises the IRQ when the fraction of a second is > 0.5, not when it is 0. Near end of each second the RTC raises UIP, begins updating its registers, and roughly 2 ms later the update ends: UIP is negated, and the interrupt is triggered. This marks the beginning of the new RTC second. > systohw reads the current system time = 1190736224.657174984 then > sleeps until 1190736225 (it wakes up at 1190736225.000003988) Nearly 4 µs of retard: not so good. Better wake earlier, and busywait for the right time. Cordialement, Serge. -- Serge point Bets arobase laposte point net _______________________________________________ questions mailing list [email protected] https://lists.ntp.org/mailman/listinfo/questions
