xref: /freebsd/share/man/man9/get_cyclecount.9 (revision 525fe93dc7487a1e63a90f6a2b956abc601963c1)
1.\" Copyright (c) 2000 Mark R V Murray
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd March 15, 2011
26.Dt GET_CYCLECOUNT 9
27.Os
28.Sh NAME
29.Nm get_cyclecount
30.Nd get the CPU's fast counter register contents
31.Sh SYNOPSIS
32.In sys/param.h
33.In sys/systm.h
34.In machine/cpu.h
35.Ft uint64_t
36.Fn get_cyclecount "void"
37.Sh DESCRIPTION
38The
39.Fn get_cyclecount
40function uses a register
41available in most modern CPUs
42to return a value
43that is monotonically increasing
44inside each CPU.
45.Pp
46On SMP systems,
47there will be a number of
48separate monotonic sequences,
49one for each CPU running.
50The value in the SMP case is
51selected from one of these sequences,
52dependent on which CPU
53was scheduled to service the request.
54.Pp
55The speed and the maximum value
56of each counter
57is CPU-dependent.
58Some CPUs
59(such as the
60.Tn Intel
6180486)
62do not have such a register,
63so
64.Fn get_cyclecount
65on these platforms
66returns a (monotonic) combination of numbers
67represented by the
68structure returned by
69.Xr binuptime 9 .
70.Pp
71The
72.Tn AMD64
73and
74.Tn Intel 64
75processors use the
76.Li TSC
77register.
78.Sh SEE ALSO
79.Xr binuptime 9
80.Sh HISTORY
81The
82.Fn get_cyclecount
83function first appeared in
84.Fx 5.0 .
85.Sh AUTHORS
86This manual page was written by
87.An Mark Murray Aq Mt markm@FreeBSD.org .
88