Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Mar 2010 17:30:14 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        Andriy Gapon <avg@icyb.net.ua>
Cc:        freebsd-hackers@FreeBSD.org
Subject:   Re: periodically save current time to time-of-day hardware
Message-ID:  <86vdcj82qx.fsf@ds4.des.no>
In-Reply-To: <4BACD88E.2040803@icyb.net.ua> (Andriy Gapon's message of "Fri, 26 Mar 2010 17:53:50 %2B0200")
References:  <4BACC791.70502@icyb.net.ua> <86zl1v84vy.fsf@ds4.des.no> <4BACD88E.2040803@icyb.net.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
Andriy Gapon <avg@icyb.net.ua> writes:
> Dag-Erling Sm=C3=B8rgrav <des@des.no> writes:
> > Andriy Gapon <avg@icyb.net.ua> writes:
> > > Also, I am aware that the period should be configurable (sysctl).
> > Why?
> Because there would always be someone who would want a different value :)
> > Although I can see an argument for a sysctl to turn it on or off.
> Good idea.

You can combine the two - P =3D=3D 0 means "don't save", P > 0 means "save
every P minutes".

> > IIRC, Linux saves the clock at shutdown, and every 11 minutes if and
> > only if the system clock is synchronized to an external reference.
> Both are good ideas too.
> I know how to add a shutdown hook (event handler), but I don't know how t=
o check
> if time synchronization is taking place.

adjtime() / adjtimex() sets a flag.  I'm not sure if (or how) the flag
is cleared when synchronization stops (i.e. /etc/rc.d/ntpd stop);
perhaps the simplest solution is to set a T =3D monotime() every time
adjtime() is called, and check that monotime() - (T * 60) < (P * 60).

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86vdcj82qx.fsf>