Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ (2) — Plan9 4th Edition

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exec(2)

cons(3)

CPUTIME(2)

NAME

cputime, times, cycles − cpu time in this process and children

SYNOPSIS

­#include <u.h>
­#include <libc.h>

longtimes(long t[4])

doublecputime(void)

voidcycles(uvlong ∗cyclep)

DESCRIPTION

If ­t is non-null, ­times fills it in with the number of milliseconds spent in user code, system calls, child processes in user code, and child processes in system calls.  ­Cputime returns the sum of those same times, converted to seconds.  ­Times returns the elapsed real time, in milliseconds, that the process has been running. 

These functions read /dev/cputime, opening that file when they are first called. 

­Cycles reads the processor’s timestamp counter of cycles since reset, if any, and stores it via cyclep. Currently supported architectures are 386, amd64, and power; on all others, ­cycles will store zero. 

SOURCE

­/sys/src/libc/9sys
­/sys/src/libc/∗/cycles.[cs]

SEE ALSO

exec(2), cons(3)

BUGS

Only ­386 processors starting with the Pentium have timestamp counters; calling ­cycles on earlier processors may execute an illegal instruction. 

Plan 9  —  February 11, 2013

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026