Timeout services provides simple functions for one-shot and cyclic use. You supply a function to be executed as a callback after the timer expires or the timeout as expressed has otherwise reached the appropriate moment. See NXTimeOutCancel and NXTimeOutSchedule.
The timeout structure, NXTimeOut_t, has fields containing the following:
The address of the callback function
A value to pass to the callback that helps identify which timeout is firing
Information about the type of timeout being set up (including the period and expiration)
If you determine that a timeout should no longer fire, it can be cancelled. It is possible to cause the cancelling thread to wait until the timeout has been successfully cancelled. Additional information as to when the timeout was successfully cancelled is available through the status argument.
In addition to time-outs, LibC also provides NXGetTime, which returns the number of units since a specifiable point in time—either boot or 1970—and is useful for simple time difference calculations. This function is based on the same underlying information from the kernel and hardware.
The following NKS functions support time and timeout management:
Returns the elapsed time. |
|
Gets the interval between two consecutive clock interrupts. |
|
Cancels a scheduled timeout. |
|
Schedules a timeout (the execution of a specified function). |
LibC also contains the standard C time functions that convert time into various formats: string, calendar (number of seconds since the epoch began), and a tm structure with fields for seconds, minutes, hours, days, month, year, etc. See Time Functions
in Volume 2.