periodically save current time to time-of-day hardware
Andriy Gapon
avg at icyb.net.ua
Fri Mar 26 14:41:25 UTC 2010
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
More information about the freebsd-hackers
mailing list