Time Management

Certain products require precise time information. The time module provides a count of clock "ticks" elapsed since system startup. This value is retrieved via the arGetTickCount function. The frequency of these ticks (ticks per second) is defined by the AR_TICKS_PER_SECOND constant.

A one-millisecond interval (1000 ticks per second) is recommended. If higher precision is required, this constant should be adjusted accordingly. Please note that time arguments passed to system functions (such as osSleep or osWaitForObject) are specified in these time units and depend directly on the value of AR_TICKS_PER_SECOND.

Time values are stored in variables of the TIME type. The definition of this type is architecture-dependent, though it is typically a 32-bit unsigned integer. This allows counting up to 232-1 before rolling over to 0. With a one-millisecond interval, rollover occurs after approximately 49.7 days. This limitation can be mitigated by using a 64-bit integer. If the operating system is in use, please refer to the Operating System Scheduling section for details on system time handling.

The following table illustrates the rollover timing for different configurations:

Type WidthTicks per secondTick intervalRollover after
32-bit10010 ms497.10 days
*32-bit1,0001 ms49.71 days
32-bit10,000100 μs119.30 hours
64-bit1,0001 ms584,142,222 years
64-bit1,000,0001 μs584,142 years
*64-bit1,000,000,0001 ns584.14 years

* Represents the recommended configuration for 32-bit and 64-bit TIME types.

Two additional special time definitions are available: AR_TIME_IGNORE, which is typically set to 0, and AR_TIME_INFINITE, which represents the maximum possible value for the TIME type. For more details, please refer to their specific descriptions.

SpaceShadow documentation