#include <nitro/os.h>
OS_SecondsToTicks( sec );
OS_SecondsToTicks32( sec );
OS_MilliSecondsToTicks( milliSec );
OS_MilliSecondsToTicks32( milliSec );
OS_MicroSecondsToTicks( microSec );
OS_MicroSecondsToTicks32( microSec );
(These are all macros.)
sec | Seconds |
milliSec | Milliseconds |
microSec | Microseconds |
The tick value that corresponds to the time specified by the argument.
This function obtains the tick value that corresponds to the time specified by the argument. One tick unit is 1/64 of the system clock.
OS_MicroSecondsTo Ticks*()
converts microseconds to tick values.OS_MilliSecondsToTicks*()
converts milliseconds to a tick value.OS_SecondsToTicks*()
converts seconds to a tick value.
These functions are all defined as macros.
Functions with 32
in their names conduct 32-bit internal calculations. Those without 32
conduct 64-bit calculations. 32-bit versions handle smaller values than 64-bit versions, so they cannot always return correct results because of overflow. However, when there is no overflow, they have the advantage of keeping the code smaller, making operating speed faster. However, since the degree of difference is not that great, and to prevent bugs, we recommend you use functions that do not include 32
in the name. Furthermore, when a constant is made into an argument, it is calculated just before compiling and the resulting value is also a constant.
When operating in 32-bit mode, be careful of overflow. Values that will cause overflow are in the following diagram.
Function Name | This value or less is OK. | Beyond this value is not allowed. |
---|---|---|
OS_SecondsToTicks32() |
128 (seconds) | 129 (seconds) |
OS_MilliSecondsToTicks32() |
128154 (Milliseconds) | 128155 (Milliseconds) |
OS_MicroSecondsToTicks32() |
128154 (Microseconds) | 128155 (Microseconds) |
Further, values that overflow in 64 bit operation are: 550419050 microseconds (about 6.4 days) for OS_MicroSecondsToTicks*()
, 550419050955 milliseconds (about 7.4 years) for OS_MilliSecondsToTicks*()
, and 550419050955 seconds (about 17,000 years) for OS_SecondsToTicks*()
.
OS_InitTick, OS_GetTick
OS_SetAlarm, OS_SetPeriodicAlarm
OS_TicksTo*Seconds
10/07/2005 Changed differences between 32 bit and 64 bit operation
10/06/2005 Considered and changed overflow for 32 bit and 64 bit operation
02/25/2004 Changed Count to Tick
02/24/2004 Initial Version