]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man9/time.9
This commit was generated by cvs2svn to compensate for changes in r66525,
[FreeBSD/FreeBSD.git] / share / man / man9 / time.9
1 .\"     $NetBSD: time.9,v 1.1 1995/11/25 21:24:53 perry 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 by Christopher G. Demetriou
17 .\"      for the NetBSD Project.
18 .\" 3. The name of the author may not be used to endorse or promote products
19 .\"    derived from this software without specific prior written permission
20 .\"
21 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 .\"
32 .\" $FreeBSD$
33 .\"
34 .Dd March 22, 1997
35 .Dt TIME 9
36 .Os FreeBSD
37 .Sh NAME
38 .Nm boottime ,
39 .Nm mono_time ,
40 .Nm runtime ,
41 .Nm time
42 .Nd system time variables
43 .Sh SYNOPSIS
44 .Va extern struct timeval boottime;
45 .br
46 .Va extern volatile struct timeval mono_time;
47 .br
48 .Va extern struct timeval runtime;
49 .br
50 .Va extern struct timeval time;
51 .Sh DESCRIPTION
52 The
53 .Va time
54 variable is the system's
55 .Dq wall time
56 clock.
57 It is set at boot by
58 .Xr inittodr 9 ,
59 and is updated by the
60 .Xr settimeofday 2
61 system call and by periodic clock interrupts.
62 .Pp
63 The
64 .Va boottime
65 variable holds the system boot time.  It is set from
66 .Va time
67 at system boot, and is updated when the system time is adjusted
68 with
69 .Xr settimeofday 2 .
70 .Pp
71 The
72 .Va runtime
73 variable holds the time that the system switched to the
74 current process.
75 It is set after each context switch, 
76 and is updated when the system time is adjusted with
77 .Xr settimeofday 2 .
78 Because
79 .Va runtime
80 is used for system accounting, it is set with the high-resolution
81 .Xr microtime 9
82 function, rather than being copied from
83 .Va time .
84 .Pp
85 The
86 .Va mono_time
87 variable is a monotonically increasing system clock.  It is set
88 from
89 .Va time
90 at boot, and is updated by the periodic timer interrupt.  (It is
91 not updated by
92 .Xr settimeofday 2 .)
93 .Pp
94 All of these variables contain times
95 expressed in seconds and microseconds since midnight (0 hour),
96 January 1, 1970.
97 .Pp
98 Clock interrupts should be blocked
99 when reading or writing
100 .Va time
101 or
102 .Va mono_time ,
103 because those variables are updated by
104 .Fn hardclock .
105 The
106 .Xr gettime 9
107 function can be used to read the
108 .Va time
109 variable in an atomic manner.  There is no equivalent
110 function for accessing
111 .Va mono_time.
112 The
113 .Va boottime
114 and
115 .Va runtime
116 variables may be read and written without special precautions.
117 .Pp
118 It should be noted that due to the differences in how the time values
119 returned by
120 .Xr gettime 9
121 and
122 .Xr microtime 9
123 are updated, comparing the results of the two routines 
124 may result in a time value that appears to go backwards.
125 This can be avoided by consistently using one function or the other
126 for use in any given context.
127 .Sh SEE ALSO
128 .Xr settimeofday 2 ,
129 .Xr gettime 9 ,
130 .\" .Xr hz 9 ,
131 .\" .Xr hardclock 9 ,
132 .Xr inittodr 9 ,
133 .Xr microtime 9
134 .Sh BUGS
135 The notion of having a single
136 .Va runtime
137 variable obviously would not be appropriate in multiprocessor systems.