xref: /freebsd/share/man/man9/get_cyclecount.9 (revision 52f1d68ff8be42d0a1e71b599187d3f83908a37c)
158550067SMark Murray.\" Copyright (c) 2000 Mark R V Murray
258550067SMark Murray.\" All rights reserved.
358550067SMark Murray.\"
458550067SMark Murray.\" Redistribution and use in source and binary forms, with or without
558550067SMark Murray.\" modification, are permitted provided that the following conditions
658550067SMark Murray.\" are met:
758550067SMark Murray.\" 1. Redistributions of source code must retain the above copyright
858550067SMark Murray.\"    notice, this list of conditions and the following disclaimer.
958550067SMark Murray.\" 2. Redistributions in binary form must reproduce the above copyright
1058550067SMark Murray.\"    notice, this list of conditions and the following disclaimer in the
1158550067SMark Murray.\"    documentation and/or other materials provided with the distribution.
1258550067SMark Murray.\"
1358550067SMark Murray.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1458550067SMark Murray.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1558550067SMark Murray.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1658550067SMark Murray.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1758550067SMark Murray.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1858550067SMark Murray.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1958550067SMark Murray.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2058550067SMark Murray.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2158550067SMark Murray.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2258550067SMark Murray.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2358550067SMark Murray.\" SUCH DAMAGE.
2458550067SMark Murray.\"
2558550067SMark Murray.\" $FreeBSD$
2658550067SMark Murray.\"
2758550067SMark Murray.Dd November 20, 2000
2852f1d68fSRuslan Ermilov.Dt GET_CYCLECOUNT 9
2958550067SMark Murray.Os
3058550067SMark Murray.Sh NAME
3123257a00SChad David.Nm get_cyclecount
3258550067SMark Murray.Nd get the CPU's fast counter register contents
3358550067SMark Murray.Sh SYNOPSIS
3432eef9aeSRuslan Ermilov.In sys/param.h
35f16b3c0dSChad David.In machine/cpufunc.h
3632eef9aeSRuslan Ermilov.In machine/cpu.h
3758550067SMark Murray.Ft u_int64_t
3823257a00SChad David.Fn get_cyclecount "void"
3958550067SMark Murray.Sh DESCRIPTION
4058550067SMark MurrayThe
4123257a00SChad David.Fn get_cyclecount
4252f1d68fSRuslan Ermilovfunction uses a register
4358550067SMark Murrayavailable in most modern CPUs
4458550067SMark Murrayto return a value
4558550067SMark Murraythat is monotonically increasing
4658550067SMark Murrayinside each CPU.
4758550067SMark Murray.Pp
4852f1d68fSRuslan ErmilovOn SMP systems,
4958550067SMark Murraythere will be a number of
5058550067SMark Murrayseparate monotonic sequences,
5158550067SMark Murrayone for each CPU running.
5258550067SMark MurrayThe value in the SMP case is
5358550067SMark Murrayselected from one of these sequences,
5458550067SMark Murraydependent on which CPU
5558550067SMark Murraywas scheduled to service the request.
5658550067SMark Murray.Pp
5752f1d68fSRuslan ErmilovThe speed and the maximum value
5858550067SMark Murrayof each counter
59e986850fSJens Schweikhardtis CPU-dependent.
6058550067SMark MurraySome CPUs
6158550067SMark Murray(such as the
6258550067SMark Murray.Tn Intel
6358550067SMark Murray80386 and 80486)
6458550067SMark Murraydo not have such a register,
6558550067SMark Murrayso
6623257a00SChad David.Fn get_cyclecount
6758550067SMark Murrayon these platforms
6858550067SMark Murrayreturns the number of nanoseconds
6958550067SMark Murrayrepresented by the
7058550067SMark Murraystructure returned by
7158550067SMark Murray.Xr nanotime 9 .
7258550067SMark Murray.Pp
7358550067SMark MurrayThe
7458550067SMark Murray.Tn Pentium
7558550067SMark Murrayprocessors all use the
7658550067SMark Murray.Li TSC
7758550067SMark Murrayregister.
7858550067SMark Murray.Pp
7958550067SMark MurrayThe
80ae9fd628SRuslan Ermilov.Tn Alpha
81ae9fd628SRuslan Ermilovprocessors use the
8258550067SMark Murray.Li PCC
8358550067SMark Murrayregister.
8458550067SMark Murray.Pp
8558550067SMark MurrayThe
8658550067SMark Murray.Tn IA64
8758550067SMark Murrayprocessors use the
8858550067SMark Murray.Li AR.ITC
8958550067SMark Murrayregister.
9058550067SMark Murray.Sh SEE ALSO
9158550067SMark Murray.Xr nanotime 9
9258550067SMark Murray.Sh HISTORY
9358550067SMark MurrayThe
9423257a00SChad David.Fn get_cyclecount
9558550067SMark Murrayfunction first appeared in
96ae9fd628SRuslan Ermilov.Fx 5.0 .
9758550067SMark Murray.Sh AUTHORS
9858550067SMark MurrayThis manual page was written by
9958550067SMark Murray.An Mark Murray Aq markm@FreeBSD.org .
100