The rules

QNX SDP8.0Getting Started with the QNX OSDeveloperUser

Let's summarize the scheduling rules (for a single CPU), in order of importance.

  • Only one thread can run at a time.
  • The highest-priority ready thread will run.
  • A thread will run until it blocks or exits.
  • An RR thread will run for its timeslice, and then the kernel will reschedule it (if required).

The following flowchart shows the decisions that the kernel makes:

Figure 1Scheduling roadmap.

Scheduling roadmap

For a multiple-CPU (SMP) system, the rules are mostly the same, but multiple CPUs can run multiple threads concurrently. The order in which the threads run (i.e., which threads get to run on the CPUs at certain times) is determined in a similar way as with a single CPU, except that the processor affinity (i.e., the binding of that thread to a specific set of CPUs) is considered in each scheduling decision. Thus, for a given CPU, the highest-priority READY thread whose processor affinity setting (i.e., its runmask) includes that CPU will run on it. For information about runmasks, refer to Processor affinity, clusters, runmasks, and inherit masks in the Programmer's Guide.

For lower-priority or longer-waiting threads, the kernel has some flexibility as to when to schedule them to avoid inefficiency in the use of the cache. For more information about SMP, see the Multicore Processing chapter of the QNX OS Programmer's Guide.

Page updated: