2.6 Time and Timeout Management Services

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:

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:

NXGetTime

Returns the elapsed time.

NXGetSystemTick

Gets the interval between two consecutive clock interrupts.

NXTimeOutCancel

Cancels a scheduled timeout.

NXTimeOutSchedule

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.