From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 26 16:30:15 2010 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6730E106564A for ; Fri, 26 Mar 2010 16:30:15 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id 29E288FC1D for ; Fri, 26 Mar 2010 16:30:14 +0000 (UTC) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 3F66A1FFC58; Fri, 26 Mar 2010 16:30:14 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id 22708844CC; Fri, 26 Mar 2010 17:30:14 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Andriy Gapon References: <4BACC791.70502@icyb.net.ua> <86zl1v84vy.fsf@ds4.des.no> <4BACD88E.2040803@icyb.net.ua> Date: Fri, 26 Mar 2010 17:30:14 +0100 In-Reply-To: <4BACD88E.2040803@icyb.net.ua> (Andriy Gapon's message of "Fri, 26 Mar 2010 17:53:50 +0200") Message-ID: <86vdcj82qx.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.95 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@FreeBSD.org Subject: Re: periodically save current time to time-of-day hardware X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Mar 2010 16:30:15 -0000 Andriy Gapon writes: > Dag-Erling Sm=C3=B8rgrav writes: > > Andriy Gapon 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