xref: /freebsd/share/man/man9/get_cyclecount.9 (revision 32eef9aeb1f39a1623cea55da147c89abbd5b9a5)
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.\"    $FreeBSD$
26.\"
27.Dd November 20, 2000
28.Dt GET_CYCLECOUNTER 9
29.Os
30.Sh NAME
31.Nm get_cyclecounter
32.Nd get the CPU's fast counter register contents
33.Sh SYNOPSIS
34.In sys/param.h
35.In machine/cpu.h
36.Ft u_int64_t
37.Fn get_cyclecounter "void"
38.Sh DESCRIPTION
39The
40.Fn get_cyclecounter
41functon uses a register
42available in most modern CPUs
43to return a value
44that is monotonically increasing
45inside each CPU.
46.Pp
47In SMP systems,
48there will be a number of
49separate monotonic sequences,
50one for each CPU running.
51The value in the SMP case is
52selected from one of these sequences,
53dependent on which CPU
54was scheduled to service the request.
55.Pp
56The speed and maximum value
57of each counter
58is CPU-dependent.
59Some CPUs
60(such as the
61.Tn Intel
6280386 and 80486)
63do not have such a register,
64so
65.Fn get_cyclecounter
66on these platforms
67returns the number of nanoseconds
68represented by the
69structure returned by
70.Xr nanotime 9 .
71.Pp
72The
73.Tn Pentium
74processors all use the
75.Li TSC
76register.
77.Pp
78The
79.Tn Alpha
80processors use the
81.Li PCC
82register.
83.Pp
84The
85.Tn IA64
86processors use the
87.Li AR.ITC
88register.
89.Sh SEE ALSO
90.Xr nanotime 9
91.Sh HISTORY
92The
93.Fn get_cyclecounter
94function first appeared in
95.Fx 5.0 .
96.Sh AUTHORS
97This manual page was written by
98.An Mark Murray Aq markm@FreeBSD.org .
99