xref: /freebsd/share/man/man9/microuptime.9 (revision 1111b49c35645b9561e28458a445684ef38c0881)
1ae5ccfadSAlexey Zelkin.\" Copyright (c) 2000 Kelly Yancey
2ae5ccfadSAlexey Zelkin.\" All rights reserved.
3ae5ccfadSAlexey Zelkin.\"
4ae5ccfadSAlexey Zelkin.\" Redistribution and use in source and binary forms, with or without
5ae5ccfadSAlexey Zelkin.\" modification, are permitted provided that the following conditions
6ae5ccfadSAlexey Zelkin.\" are met:
7ae5ccfadSAlexey Zelkin.\" 1. Redistributions of source code must retain the above copyright
8ae5ccfadSAlexey Zelkin.\"    notice, this list of conditions and the following disclaimer.
9ae5ccfadSAlexey Zelkin.\" 2. Redistributions in binary form must reproduce the above copyright
10ae5ccfadSAlexey Zelkin.\"    notice, this list of conditions and the following disclaimer in the
11ae5ccfadSAlexey Zelkin.\"    documentation and/or other materials provided with the distribution.
12ae5ccfadSAlexey Zelkin.\"
13ae5ccfadSAlexey Zelkin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14ae5ccfadSAlexey Zelkin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15ae5ccfadSAlexey Zelkin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16ae5ccfadSAlexey Zelkin.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17ae5ccfadSAlexey Zelkin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18ae5ccfadSAlexey Zelkin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19ae5ccfadSAlexey Zelkin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20ae5ccfadSAlexey Zelkin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21ae5ccfadSAlexey Zelkin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22ae5ccfadSAlexey Zelkin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23ae5ccfadSAlexey Zelkin.\" SUCH DAMAGE.
24ae5ccfadSAlexey Zelkin.\"
25ae5ccfadSAlexey Zelkin.\"    $FreeBSD$
26ae5ccfadSAlexey Zelkin.\"
27ae5ccfadSAlexey Zelkin.Dd January 3, 2000
28ae5ccfadSAlexey Zelkin.Dt MICROUPTIME 9
29ae5ccfadSAlexey Zelkin.Os FreeBSD
30ae5ccfadSAlexey Zelkin.Sh NAME
31ae5ccfadSAlexey Zelkin.Nm microuptime ,
32ae5ccfadSAlexey Zelkin.Nm getmicrouptime ,
33ae5ccfadSAlexey Zelkin.Nm nanouptime ,
34ae5ccfadSAlexey Zelkin.Nm getnanouptime
35ae5ccfadSAlexey Zelkin.Nd get the time elapsed since boot
36ae5ccfadSAlexey Zelkin.Sh SYNOPSIS
37ae5ccfadSAlexey Zelkin.Fd #include <sys/time.h>
38ae5ccfadSAlexey Zelkin.Ft void
39ae5ccfadSAlexey Zelkin.Fn microuptime "struct timeval *tv"
40ae5ccfadSAlexey Zelkin.Ft void
41ae5ccfadSAlexey Zelkin.Fn getmicrouptime "struct timeval *tv"
42ae5ccfadSAlexey Zelkin.Ft void
43ae5ccfadSAlexey Zelkin.Fn nanouptime "struct timespec *ts"
44ae5ccfadSAlexey Zelkin.Ft void
45ae5ccfadSAlexey Zelkin.Fn getnanouptime "struct timespec *tsp"
46ae5ccfadSAlexey Zelkin.Sh DESCRIPTION
47ae5ccfadSAlexey ZelkinThe
48ae5ccfadSAlexey Zelkin.Fn microuptime
49ae5ccfadSAlexey Zelkinand
50ae5ccfadSAlexey Zelkin.Fn getmicrouptime
51ae5ccfadSAlexey Zelkinfunctions store the time elapsed since boot as a
52ae5ccfadSAlexey Zelkin.Ft struct timeval
53ae5ccfadSAlexey Zelkinat the address specified by
54ae5ccfadSAlexey Zelkin.Fa tv .
55ae5ccfadSAlexey ZelkinThe
56ae5ccfadSAlexey Zelkin.Fn nanouptime
57ae5ccfadSAlexey Zelkinand
58ae5ccfadSAlexey Zelkin.Fn getnanouptime
59ae5ccfadSAlexey Zelkinfunctions perform the same utility, but record the elapsed time as a
60ae5ccfadSAlexey Zelkin.Ft struct timespec
61ae5ccfadSAlexey Zelkininstead.
62ae5ccfadSAlexey Zelkin.Pp
63ae5ccfadSAlexey Zelkin.Fn Microuptime
64ae5ccfadSAlexey Zelkinand
65ae5ccfadSAlexey Zelkin.Fn nanouptime
66ae5ccfadSAlexey Zelkinalways query the timecounter to return the current time as precisely as
671111b49cSSheldon Hearnpossible.
681111b49cSSheldon HearnWhereas
69ae5ccfadSAlexey Zelkin.Fn getmicrouptime
70ae5ccfadSAlexey Zelkinand
71ae5ccfadSAlexey Zelkin.Fn getnanouptime
72ae5ccfadSAlexey Zelkinfunctions are abstractions which can alternately return a less precise, but
731111b49cSSheldon Hearnfaster to obtain, time.
741111b49cSSheldon HearnThis behaviour can be toggled via the
75ae5ccfadSAlexey Zelkinkern.timecounter.method sysctl variable:
76ae5ccfadSAlexey Zelkin.Bl -tag -width ABC
77ae5ccfadSAlexey Zelkin.It Dv 0
78ae5ccfadSAlexey Zelkinsacrifice precision in favor of faster code execution
79ae5ccfadSAlexey Zelkin.It Dv 1
80ae5ccfadSAlexey Zelkinreturn the more precise time (the same as calling
81ae5ccfadSAlexey Zelkin.Fn microuptime
82ae5ccfadSAlexey Zelkinor
83ae5ccfadSAlexey Zelkin.Fn nanouptime ) .
84ae5ccfadSAlexey Zelkin.El
85ae5ccfadSAlexey Zelkin.Pp
86ae5ccfadSAlexey ZelkinThe intent of the
87ae5ccfadSAlexey Zelkin.Fn getmicrouptime
88ae5ccfadSAlexey Zelkinand
89ae5ccfadSAlexey Zelkin.Fn getnanouptime
90ae5ccfadSAlexey Zelkinfunctions is to enforce the user's preference for timer accuracy versus
91ae5ccfadSAlexey Zelkinexecution time.
92ae5ccfadSAlexey Zelkin.Sh SEE ALSO
93ae5ccfadSAlexey Zelkin.Xr getmicrotime 9 ,
94ae5ccfadSAlexey Zelkin.Xr getnanotime 9 ,
95ae5ccfadSAlexey Zelkin.Xr microtime 9 ,
96ae5ccfadSAlexey Zelkin.Xr nanotime 9 ,
97ae5ccfadSAlexey Zelkin.Xr tvtohz 9
98ae5ccfadSAlexey Zelkin.Sh DIAGNOSTICS
99ae5ccfadSAlexey ZelkinBuggy hardware can cause "calcru negative..." when kern.timecounter.method
100ae5ccfadSAlexey Zelkinis set to 0.
101ae5ccfadSAlexey Zelkin.Sh AUTHORS
102ae5ccfadSAlexey ZelkinThis manual page was written by
103ae5ccfadSAlexey Zelkin.An Kelly Yancey Aq kbyanc@posi.net .
104