xref: /netbsd-src/share/man/man9/time_second.9 (revision 627f7eb200a4419d89b531d55fccd2ee3ffdcde0)
1.\" $NetBSD: time_second.9,v 1.9 2020/04/18 18:55:20 wiz Exp $
2.\"
3.\" Copyright (c) 1994 Christopher G. Demetriou
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"          This product includes software developed for the
17.\"          NetBSD Project.  See http://www.NetBSD.org/ for
18.\"          information about NetBSD.
19.\" 4. The name of the author may not be used to endorse or promote products
20.\"    derived from this software without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32.\"
33.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
34.\"
35.Dd April 17, 2020
36.Dt TIME_SECOND 9
37.Os
38.Sh NAME
39.Nm time_second ,
40.Nm time_uptime
41.Nd system time variables
42.Sh SYNOPSIS
43.In sys/time.h
44.Vt extern time_t time_second;
45.Vt extern time_t time_uptime;
46.Sh DESCRIPTION
47The
48.Va time_second
49variable is the system's
50.Dq wall time
51clock.
52It is set at boot by
53.Xr inittodr 9 ,
54and is updated periodically via
55.Xr timecounter 9
56framework, and also updated by the
57.Xr settimeofday 2
58system call.
59.Pp
60The
61.Va time_uptime
62variable is a monotonically increasing system clock.
63It is set at boot, and is updated periodically.
64(It is not updated by
65.Xr settimeofday 2 . )
66.Pp
67All of these variables contain times
68expressed in seconds since midnight (0 hour),
69January 1, 1970, UTC.
70.Pp
71The
72.Xr bintime 9 ,
73.Xr getbintime 9 ,
74.Xr microtime 9 ,
75.Xr getmicrotime 9 ,
76.Xr nanotime 9 ,
77and
78.Xr getnanotime 9
79functions can be used to get the current time more accurately and in an
80atomic manner.
81.Pp
82Similarly, the
83.Xr binuptime 9 ,
84.Xr getbinuptime 9 ,
85.Xr microuptime 9 ,
86.Xr getmicrouptime 9 ,
87.Xr nanouptime 9 ,
88and
89.Xr getnanouptime 9
90functions can be used to get the time elapsed since boot more accurately
91and in an atomic manner.
92.Sh SEE ALSO
93.Xr clock_settime 2 ,
94.Xr ntp_adjtime 2 ,
95.Xr timespec 3 ,
96.Xr hardclock 9 ,
97.Xr hz 9
98