1.\" $NetBSD: time_second.9,v 1.5 2011/03/13 05:03:21 jruoho 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 March 13, 2008 36.Dt TIME_SECOND 9 37.Os 38.Sh NAME 39.Nm time_second , 40.Nm time_uptime , 41.Nm boottime 42.Nd system time variables 43.Sh SYNOPSIS 44.In sys/time.h 45.Vt extern time_t time_second; 46.Vt extern time_t time_uptime; 47.In sys/kernel.h 48.Vt extern struct timeval boottime; 49.Sh DESCRIPTION 50The 51.Va time_second 52variable is the system's 53.Dq wall time 54clock. 55It is set at boot by 56.Xr inittodr 9 , 57and is updated periodically via 58.Xr timecounter 9 59framework, and also updated by the 60.Xr settimeofday 2 61system call. 62.Pp 63The 64.Va time_uptime 65variable is a monotonically increasing system clock. 66It is set at boot, and is updated periodically. 67(It is not updated by 68.Xr settimeofday 2 . ) 69.Pp 70The 71.Va boottime 72variable holds the system boot time. 73It is set at system boot, and is updated when the system time is adjusted 74with 75.Xr settimeofday 2 . 76The variable may be read and written without special precautions. 77.Pp 78All of these variables contain times 79expressed in seconds and microseconds since midnight (0 hour), 80January 1, 1970. 81.Pp 82The 83.Xr bintime 9 , 84.Xr getbintime 9 , 85.Xr microtime 9 , 86.Xr getmicrotime 9 , 87.Xr nanotime 9 , 88and 89.Xr getnanotime 9 90functions can be used to get the current time more accurately and in an 91atomic manner. 92.Pp 93Similarly, the 94.Xr binuptime 9 , 95.Xr getbinuptime 9 , 96.Xr microuptime 9 , 97.Xr getmicrouptime 9 , 98.Xr nanouptime 9 , 99and 100.Xr getnanouptime 9 101functions can be used to get the time elapsed since boot more accurately 102and in an atomic manner. 103.Sh SEE ALSO 104.Xr clock_settime 2 , 105.Xr ntp_adjtime 2 , 106.Xr timeval 3 , 107.Xr hardclock 9 , 108.Xr hz 9 109