Priority range

Threads can have a scheduling priority ranging from 1 to 255 (the highest priority), independent of the scheduling policy.

Unprivileged threads can have a priority ranging from 1 to 63 (by default); root threads (i.e. those with an effective uid of 0) and those 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 special idle thread (in the process manager) has priority 0 and is always ready to run. A thread inherits the priority of its parent thread by default.

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.

Interrupt handlers are of higher priority than any thread, but they're not scheduled in the same way as threads. If an interrupt occurs, then:

  1. Whatever thread was running loses the CPU handling the interrupt (SMP issues).
  2. The hardware runs the kernel.
  3. The kernel calls the appropriate interrupt handler.
Figure showing thread priorities in the range from 0 (lowest) to 255 (highest).

Although interrupt handlers aren't scheduled in the same way as threads, they're considered to be of a higher priority because an interrupt handler will preempt any running thread.