[rtems commit] kern: clarify boot time

Jan Sommer jan at rtems.org
Tue Nov 30 14:39:58 UTC 2021


Module:    rtems
Branch:    5
Commit:    1ca98b274bab9b4392157f088a325f68a919ffa7
Changeset: http://git.rtems.org/rtems/commit/?id=1ca98b274bab9b4392157f088a325f68a919ffa7

Author:    Warner Losh <imp at FreeBSD.org>
Date:      Wed May  5 12:32:13 2021 -0600

kern: clarify boot time

In FreeBSD, the current time is computed from uptime + boottime. Uptime
is a continuous, smooth function that's monotonically increasing. To
effect changes to the current time, boottime is adjusted.  boottime is
mutable and shouldn't be cached against future need. Document the
current implementation, with the caveat that we may stop stepping
boottime on resume in the future and will step uptime instead (noted in
the commit message, but not in the code).

Sponsored by:		Netflix
Reviewed by:		phk, rpokala
Differential Revision:	https://reviews.freebsd.org/D30116

---

 cpukit/score/src/kern_tc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index 5e0b6fa..076139e 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -235,11 +235,17 @@ volatile int32_t time_uptime = 1;
 #endif /* __rtems__ */
 
 #ifndef __rtems__
+/*
+ * The system time is always computed by summing the estimated boot time and the
+ * system uptime. The timehands track boot time, but it changes when the system
+ * time is set by the user, stepped by ntpd or adjusted when resuming. It
+ * is set to new_time - uptime.
+ */
 static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS);
 SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime,
     CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
     sysctl_kern_boottime, "S,timeval",
-    "System boottime");
+    "Estimated system boottime");
 
 SYSCTL_NODE(_kern, OID_AUTO, timecounter, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
     "");



More information about the vc mailing list