]> git.lizzy.rs Git - plan9front.git/blob - sys/man/2/cputime
arm64: use generic timer virtual counter for cycles()
[plan9front.git] / sys / man / 2 / cputime
1 .TH CPUTIME 2
2 .SH NAME
3 cputime, times, cycles \- cpu time in this process and children
4 .SH SYNOPSIS
5 .B #include <u.h>
6 .br
7 .B #include <libc.h>
8 .PP
9 .ta \w'\fLdouble 'u
10 .B
11 long    times(long t[4])
12 .PP
13 .B
14 double  cputime(void)
15 .PP
16 .B
17 void    cycles(uvlong *cyclep)
18 .SH DESCRIPTION
19 If
20 .I t
21 is non-null,
22 .I times
23 fills it in
24 with the number of milliseconds spent in user code, system calls,
25 child processes in user code, and child processes in system calls.
26 .I Cputime
27 returns the sum of those same times, converted to seconds.
28 .I Times
29 returns the elapsed real time, in milliseconds, that the process has been running.
30 .PP
31 These functions read
32 .BR /dev/cputime ,
33 opening that file when they are first called.
34 .PP
35 .I Cycles
36 reads the processor's timestamp counter of cycles since reset,
37 if any, and stores it via
38 .IR cyclep .
39 Currently supported architectures are
40 .BR 386 ,
41 .BR amd64 ,
42 .B arm64
43 and
44 .BR power ;
45 on all others,
46 .I cycles
47 will store zero.
48 .SH SOURCE
49 .B /sys/src/libc/9sys
50 .br
51 .B /sys/src/libc/*/cycles.[cs]
52 .SH SEE ALSO
53 .IR exec (2),
54 .IR cons (3)
55 .SH BUGS
56 Only
57 .B 386
58 processors starting with the Pentium have timestamp counters;
59 calling
60 .I cycles
61 on earlier processors may execute an illegal instruction.