osGetCount osGetCount (function)

osGetCount

Returns CPU count register

Syntax

#include <ultra64.h>     /* ultra64.h */
u32 osGetCount(void);

Description

The osGetCount routine returns the value of the MIPS R4300 count register, which is incremented at half the speed of the CPU clock. Since this counter increments at 46.875 MHz, 1 cycle represents around 21.33 nanoseconds. When the counter reaches its maximum value it returns to zero and continues to increment. The counter has a length of 32 bits, so it will repeat approximately every 92 seconds. Macros like OS_CYCLES_TO_NSEC are available for converting between the counter and time units of nanoseconds or microseconds.

The counter value may be used as a pseudo-random number generator or for short-duration timing purposes.

See Also

OS_CYCLES_TO_NSEC, osTvType, and osGetTime

Revision History

1999/06/15 Completely rewritten