From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 26 14:41:25 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 5E2DD1065672 for ; Fri, 26 Mar 2010 14:41:25 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id A74AD8FC13 for ; Fri, 26 Mar 2010 14:41:24 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id QAA04268 for ; Fri, 26 Mar 2010 16:41:22 +0200 (EET) (envelope-from avg@icyb.net.ua) Message-ID: <4BACC791.70502@icyb.net.ua> Date: Fri, 26 Mar 2010 16:41:21 +0200 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.24 (X11/20100319) MIME-Version: 1.0 To: freebsd-hackers@FreeBSD.org X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Subject: 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 14:41:25 -0000 What do you think about the following patch or something similar? Just in case, I am already aware about missing empty lines before the code in the new functions. Also, I am aware that the period should be configurable (sysctl). Reference: http://lists.freebsd.org/pipermail/freebsd-hardware/2009-March/005828.html --- a/sys/kern/subr_clock.c +++ b/sys/kern/subr_clock.c @@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -76,6 +78,24 @@ sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_machdep, OID_AUTO, adjkerntz, CTLTYPE_INT|CTLFLAG_RW, &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", ""); +static void +periodic_resettodr(void *arg __unused) +{ + mtx_lock(&Giant); + resettodr(); + mtx_unlock(&Giant); + timeout(periodic_resettodr, NULL, 1800 * hz); +} + +static void +start_periodic_resettodr(void *arg __unused) +{ + timeout(periodic_resettodr, NULL, 1800 * hz); +} + +SYSINIT(periodic_resettodr, SI_SUB_RUN_SCHEDULER, SI_ORDER_ANY, + start_periodic_resettodr, NULL); + /*--------------------------------------------------------------------* * Generic routines to convert between a POSIX date * (seconds since 1/1/1970) and yr/mo/day/hr/min/sec -- Andriy Gapon