Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Mar 2010 16:41:21 +0200
From:      Andriy Gapon <avg@icyb.net.ua>
To:        freebsd-hackers@FreeBSD.org
Subject:   periodically save current time to time-of-day hardware
Message-ID:  <4BACC791.70502@icyb.net.ua>

next in thread | raw e-mail | index | archive | help


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 <sys/kernel.h>
 #include <sys/bus.h>
 #include <sys/clock.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/sysctl.h>
 #include <sys/timetc.h>

@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4BACC791.70502>