summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2021-05-05 12:32:13 -0600
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-10-12 13:54:23 +0200
commitf4ccb53584423ce7096050ac09cd4faa5523b07d (patch)
treea79d645ba7dff73c51c168533e551feefbeb876f
parenta865a5d5e0c6f8b61b9ac1e4c16f2f0fc327ea1b (diff)
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
-rw-r--r--cpukit/score/src/kern_tc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index 7567def9bd..6dafce79dd 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -252,11 +252,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,
"");