SECONDS(9) SECONDS(9)
NAME
seconds, ticks, fastticks, HZ, MS2HZ, MS2TK, TK2MS, TK2SEC -
kernel times and time conversions
SYNOPSIS
long seconds(void)
m->ticks
MACHP(0)->ticks
vlong fastticks(uvlong *hz)
#define HZ ...
#define MS2HZ(t) ...
#define TK2SEC(t) ...
#define TK2MS(t) ...
#define MS2TK(m) ...
DESCRIPTION
Seconds returns the system's idea of the current time as the
number of seconds since the start of the epoch (00:00:00
GMT, January 1, 1970).
The ticks field of the Mach structure pointed to by m
returns the number of system-dependent clock ticks on the
given processor since system boot. On a multiprocessor,
MACHP(0) is sometimes used to provide a reference time,
since the tick value might vary slightly across processors.
Fastticks returns the number of ticks since boot as measured
by the fastest clock provided by the platform. The fre-
quency of the clock, in ticks per second, is returned
through hz, unless it is nil.
The system clock frequencies are platform-dependent. Sev-
eral symbolic constants and macro functions are defined by
the file mem.h to convert between different time units:
HZ The number of clock ticks per second.
MS2HZ Milliseconds per clock tick.
TK2SEC(t) Convert t clock ticks to seconds and return the
result (truncating not rounding).
TK2MS(t) Convert t clock ticks to milliseconds and return
the result.
MS2TK(m) Convert m milliseconds to clock ticks and return
Page 1 Plan 9 (printed 12/22/25)
SECONDS(9) SECONDS(9)
the result (truncating).
The functions are often used to calculate delays for timing
functions, for instance:
if(atactlrwait(dp->cp, DHmagic, 0, MS2TK(100))){
...
}
SOURCE
/sys/src/9/*/mem.h
/sys/src/9/*/clock.c
/sys/src/9/port/tod.c
Page 2 Plan 9 (printed 12/22/25)