seconds, ticks, fastticks, HZ, MS2HZ, MS2TK, TK2MS, TK2SEC – kernel times and time conversions


long seconds(void)

vlong fastticks(uvlong *hz)

#define	HZ          ...
#define	MS2HZ       (1000/HZ)
#define	TK2SEC(t)   ((t)/HZ)
#define	TK2MS(t)    ((t)*(1000/HZ))


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 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 frequency of the clock, in ticks per second, is returned through hz, unless it is nil.

The system clock frequencies are platform-dependent. Several symbolic constants and macro functions are defined by the file mem.h to convert between different time units:


The number of clock ticks per second.  


Milliseconds per clock tick.  


Convert t clock ticks to seconds (truncating not rounding).  


Convert t clock ticks to milliseconds.