If you use nanosleep() to put a thread to sleep and in the meantime other processes may change CLOCK_REALTIME clock with ClockTime() or clock_settime(), then please consider using clock_nanosleep() and specify the clock_id to be CLOCK_MONOTONIC.
Here is the reason. There are two types of system clocks. The CLOCK_MONOTONIC clock keeps a monotonically increasing count of clock ticks since system bootup. The CLOCK_REALTIME keeps the time of day clock by adding an adjustment to the CLOCK_MONOTONIC clock count. When nanosleep() is called, a timeout value is calculated based on the the CLOCK_MONOTONIC count and the "TOD" adjustment at that moment. If a process calls ClockTime() to set a new time of day afterwards, the adjustment part will be changed according to the new value. When the right wakeup moment comes, the "TOD" adjustment is no longer the original value therefore nanosleep() misses the right wakeup moment.
NOTE:
This entry has been validated against the SDP version listed above. Use
caution when considering this advice for any other SDP version. For
supported releases, please reach out toQNX Technical Support if you have any questions/concerns.