Summary

Updated: October 28, 2024

We've looked at QNX Neutrino's time-based functions, including timers and how they can be used, as well as kernel timeouts. Relative timers provide some form of event “in a certain number of seconds,” while absolute timers provide this event “at a certain time.” Timers (and, generally speaking, the struct sigevent) can cause the delivery of a pulse or a signal, or the creation of a thread.

The kernel implements timers by storing the absolute time that represents the next “event” on a sorted queue, and comparing the current time (as derived by the timer tick interrupt service routine) against the head of the sorted queue. When the current time is greater than or equal to the first member of the queue, the queue is processed (for all matching entries) and the kernel dispatches events or threads (depending on the type of queue entry) and (possibly) reschedules.

To provide support for power-saving features, you should disable periodic timers when they're not needed—otherwise, the power-saving feature won't engage, because it believes that there's something to “do” periodically. You could also use the CLOCK_SOFTTIME clock source, unless of course you actually wanted the timer to defeat the power-saving feature.

Given the different types of clock sources, you have flexibility in determining the basis of your clocks and timer; from “real, elapsed” time through to time sources based on power-management activities.