xref: /freebsd/share/man/man9/get_cyclecount.9 (revision ae9fd6288cf2819976a1a61d6c3bbdb062b0e465)
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
28ae9fd628SRuslan Ermilov.Dt GET_CYCLECOUNTER 9
2958550067SMark Murray.Os
3058550067SMark Murray.Sh NAME
3158550067SMark Murray.Nm get_cyclecounter
3258550067SMark Murray.Nd get the CPU's fast counter register contents
3358550067SMark Murray.Sh SYNOPSIS
3458550067SMark Murray.Fd #include <sys/types.h>
3558550067SMark Murray.Fd #include <machine/cpu.h>
3658550067SMark Murray.Ft u_int64_t
3758550067SMark Murray.Fn get_cyclecounter "void"
3858550067SMark Murray.Sh DESCRIPTION
3958550067SMark MurrayThe
4058550067SMark Murray.Fn get_cyclecounter
4158550067SMark Murrayfuncton uses a register
4258550067SMark Murrayavailable in most modern CPUs
4358550067SMark Murrayto return a value
4458550067SMark Murraythat is monotonically increasing
4558550067SMark Murrayinside each CPU.
4658550067SMark Murray.Pp
4758550067SMark MurrayIn SMP systems,
4858550067SMark Murraythere will be a number of
4958550067SMark Murrayseparate monotonic sequences,
5058550067SMark Murrayone for each CPU running.
5158550067SMark MurrayThe value in the SMP case is
5258550067SMark Murrayselected from one of these sequences,
5358550067SMark Murraydependent on which CPU
5458550067SMark Murraywas scheduled to service the request.
5558550067SMark Murray.Pp
5658550067SMark MurrayThe speed and maximum value
5758550067SMark Murrayof each counter
5858550067SMark Murrayis CPU-dependant.
5958550067SMark MurraySome CPUs
6058550067SMark Murray(such as the
6158550067SMark Murray.Tn Intel
6258550067SMark Murray80386 and 80486)
6358550067SMark Murraydo not have such a register,
6458550067SMark Murrayso
6558550067SMark Murray.Fn get_cyclecounter
6658550067SMark Murrayon these platforms
6758550067SMark Murrayreturns the number of nanoseconds
6858550067SMark Murrayrepresented by the
6958550067SMark Murraystructure returned by
7058550067SMark Murray.Xr nanotime 9 .
7158550067SMark Murray.Pp
7258550067SMark MurrayThe
7358550067SMark Murray.Tn Pentium
7458550067SMark Murrayprocessors all use the
7558550067SMark Murray.Li TSC
7658550067SMark Murrayregister.
7758550067SMark Murray.Pp
7858550067SMark MurrayThe
79ae9fd628SRuslan Ermilov.Tn Alpha
80ae9fd628SRuslan Ermilovprocessors use the
8158550067SMark Murray.Li PCC
8258550067SMark Murrayregister.
8358550067SMark Murray.Pp
8458550067SMark MurrayThe
8558550067SMark Murray.Tn IA64
8658550067SMark Murrayprocessors use the
8758550067SMark Murray.Li AR.ITC
8858550067SMark Murrayregister.
8958550067SMark Murray.Sh SEE ALSO
9058550067SMark Murray.Xr nanotime 9
9158550067SMark Murray.Sh HISTORY
9258550067SMark MurrayThe
93ae9fd628SRuslan Ermilov.Fn get_cyclecounter
9458550067SMark Murrayfunction first appeared in
95ae9fd628SRuslan Ermilov.Fx 5.0 .
9658550067SMark Murray.Sh AUTHORS
9758550067SMark MurrayThis manual page was written by
9858550067SMark Murray.An Mark Murray Aq markm@FreeBSD.org .
99