periodically save current time to time-of-day hardware

Dag-Erling Smørgrav des at des.no
Sat Mar 27 00:38:38 UTC 2010


Peter Jeremy <peterjeremy at acm.org> writes:
> It's not especially important how regularly the RTC is updated, just
> that it _is_ updated.  This suggests that an alternative approach
> would be for adjtime() / ntp_adjtime() to directly call resettodr() if
> it's more than P minutes since resettodr() was last called.

It just occurred to me that resettodr() is very slow (it usually
involves writing to NVRAM over an I2C bus), so it might not be a good
idea to call it from adjtime().

> As a general comment, whilst resettodr() needs to be serialised, there
> is no need for it to block.  If thread B wants to call resettodr()
> whilst thread A is doing so, thread B can just skip the call because
> calling resettodr() twice in quick succession has no benefit.

It does if thread B set the system clock before calling resettodr()
(think ntpd -gq).  Actually, it might be a good idea to call resettodr()
any time the clock is stepped.

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-hackers mailing list