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 September 17, 2004 35.Dt TIME 9 36.Os 37.Sh NAME 38.In sys/time.h 39.Nm boottime , 40.Nm time_second , 41.Nm time_uptime 42.Nd system time variables 43.Sh SYNOPSIS 44.Bl -item -compact 45.It 46.Va extern struct timeval boottime ; 47.It 48.Va extern struct time_t time_second ; 49.It 50.Va extern struct timeval time_uptime ; 51.El 52.Sh DESCRIPTION 53The 54.Va boottime 55variable holds the system boot time. 56.Pp 57The 58.Va time_second 59variable is the system's 60.Dq wall time 61clock to the second. 62.Pp 63The 64.Va time_uptime variable is the number of seconds since boot. 65.Pp 66The 67.Xr bintime 9, 68.Xr getbintime 9 , 69.Xr microtime 9 , 70.Xr getmicrotime 9 , 71.Xr nanotime 9 , 72and 73.Xr getnanotime 9 , 74functions can be used to get the current time more accurately and in an 75atomic manner. 76Similarly, the 77The 78.Xr binuptime 9, 79.Xr getbinuptime 9 , 80.Xr microuptime 9 , 81.Xr getmicrouptime 9 , 82.Xr nanouptime 9 , 83and 84.Xr getnanouptime 9 , 85functions can be used to get the time elapse since boot more accurately 86and in an atomic manner. 87The 88.Va boottime 89variable may be read and written without special precautions. 90.Pp 91.Sh SEE ALSO 92.Xr clock_settime 2 , 93.Xr ntp_adjtime 2 , 94.Xr settimeofday 2 , 95.Xr getbintime 9 , 96.Xr getbinuptime 9 , 97.Xr getmicrotime 9 , 98.Xr getmicrouptime 9 , 99.Xr getnanotime 9 , 100.Xr getnanouptime 9 , 101.Xr bintime 9 , 102.Xr binuptime 9 , 103.Xr microtime 9 , 104.Xr microuptime 9 , 105.Xr nanotime 9, 106.Xr nanouptime 9 107.Rs 108.%A "Poul-Henning Kamp" 109.%T "Timecounters: Efficient and precise timekeeping in SMP kernels" 110.%J "Proceedings of EuroBSDCon 2002" 111.%C "Amsterdam" 112.%O /usr/share/doc/papers/timecounter.ascii.gz 113.Re 114.Rs 115.%A "Marshall Kirk McKusick" 116.%A "George V. Neville-Neil" 117.%B "The Design and Implementation of the FreeBSD Operating System" 118.%D "July 2004" 119.%I "Addison-Wesley" 120.%P "57-61,65-66" 121.Re 122