Page MenuHomeFreeBSD

D30116.diff
No OneTemporary

D30116.diff

diff --git a/share/man/man9/time.9 b/share/man/man9/time.9
--- a/share/man/man9/time.9
+++ b/share/man/man9/time.9
@@ -31,7 +31,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 17, 2004
+.Dd May 4, 2021
.Dt TIME 9
.Os
.Sh NAME
@@ -48,7 +48,18 @@
.Sh DESCRIPTION
The
.Va boottime
-variable holds the system boot time.
+variable holds the estimated system boot time.
+This time is initially set when the system boots, either from the RTC, or from a
+time estimated from the system's root filesystem.
+When the current system time is set, stepped by
+.Xr ntpd 8 ,
+or a new time is read from the RTC as the system resumes,
+.Va boottime
+is recomputed as new_time - uptime.
+The
+.Xr sysctl 8
+.Va kern.boottime
+returns this value.
.Pp
The
.Va time_second
@@ -83,6 +94,7 @@
The
.Va boottime
variable may be read and written without special precautions.
+It is adjusted when the phase of the system time changes.
.Sh SEE ALSO
.Xr clock_settime 2 ,
.Xr ntp_adjtime 2 ,
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -103,11 +103,17 @@
volatile time_t time_second = 1;
volatile time_t time_uptime = 1;
+/*
+ * 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,
"");

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 6:12 PM (21 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14563853
Default Alt Text
D30116.diff (1 KB)

Event Timeline