Priority range

QNX SDP8.0Programmer's GuideDeveloper
Threads can have a scheduling priority ranging from 0 to 255 (the highest priority), independent of the scheduling policy, but three priorities are reserved for system threads:
  • 0 — per-processor idle thread
  • 254 — per-processor clock IST (but is configurable)
  • 255 — per-processor IPI IST
A thread inherits the priority of its parent thread by default.

Unprivileged threads can have a priority ranging from 1 to 63 (by default); threads with the PROCMGR_AID_PRIORITY ability enabled (see procmgr_ability()) are allowed to set priorities above 63. You can change the allowed priority range for unprivileged processes with the procnto -P option.

The process manager has a set of special idle threads (one per available CPU core) that have priority 0 and are always ready to run. A CPU core is considered to be idle when the idle thread is scheduled to run on that core. At any instant, a core is either idle or busy; only by averaging over time can a CPU be said to be some percent busy (e.g., 75% CPU usage).

A thread has both a real priority and an effective priority, and is scheduled in accordance with its effective priority. The thread itself can change both its real and effective priority together, but the effective priority may change because of priority inheritance or the scheduling policy. Normally, the effective priority is the same as the real priority.

ISTs don't have a higher priority than any other thread, as they are just regular threads. However, if you're attaching an event rather than an IST, you can set the priority of the implicitly created IST by calling InterruptAttachEventPriority() instead of InterruptAttachEvent().
  1. Whatever thread was running loses the CPU on the core that's handling the interrupt. On multicore machines this may vary, due to hardware configuration and BSP setup.
  2. The kernel runs some hardware-specific code supplied by the BSP to identify the interrupt.
  3. The kernel masks the interrupt, then posts a semaphore to unblock the appropriate IST.
  4. The kernel runs some hardware-specific code supplied by the BSP to do end-of-interrupt processing.
Figure 1Thread priorities range from 0 (lowest) to 255 (highest).

Figure showing thread priorities

Out-of-range priority requests

As an extension to POSIX, when you're setting a priority, you can wrap it in one these macros to specify how to handle out-of-range priority requests:
  • SCHED_PRIO_LIMIT_ERROR(priority) — indicate an error
  • SCHED_PRIO_LIMIT_SATURATE(priority) — use the maximum allowed priority (reach a maximum saturation point)

You can append an s or S to procnto's -P option if you want out-of-range priority requests by default to saturate at the maximum allowed value instead of resulting in an error.

Page updated: