Base timing resolution

Let's say that the timer tick is operating at just slightly faster than 10 ms. Can I reliably sleep for 3 milliseconds?

Nope (or at least, not originally).

Consider what happens in the kernel. You issue the C-library delay() call to go to sleep for 3 milliseconds. The kernel has to set the variable in the ISR to some value. If it sets it to the current time, this means the timer has already expired and that you should wake up immediately. If it sets it to one tick more than the current time, this means that you should wake up on the next tick (up to 10 milliseconds away).

The moral of this story is: “Don't expect timing resolution any better than the input timer tick rate.”

This has changed; in QNX Neutrino 7.0 and later, you can use a high-resolution timer. For details, see Tolerant and high-resolution timers in the Tick, Tock: Understanding the Microkernel's Concept of Time chapter of the Programmer's Guide.

Getting more precision

Under QNX Neutrino, a program can adjust the value of the hardware divisor component in conjunction with the kernel (so that the kernel knows what rate the timer tick ISR is being called at). We'll look at this below in the Getting and setting the realtime clock section.