Selecting the Next Ready Process

Selecting a Ready Process in XINU

Remember that a process that would like to run but does not currently have control of the CPU (is waiting for its turn at the CPU) is called a ready process. The one (in a uni-processor) process that is currently running is called the running or current process.

XINU process scheduling follows the same rules that were followed in PThreads, namely that at any time, the process with the highest priority is the running process (assuming that process actually wants the CPU and isn't therefore blocked). If there is more than one process at the highest priority, then these processes are run in a round-robin fashion.

As indicated above, XINU process priorities are simply positive integers. There is one queue of ready processes (remember back to the section on XINU lists). This queue is a XINU priority queue. The process priority is stored in the key field of the queue entries (as well as in the process' PCB).

Remember that priority queues in XINU are ordered from low to high value. This makes selecting the next process to run a simple matter of selecting the process at the tail of the ready list. When inserting a process into a priority queue, XINU starts at the head and moves toward the tail to find the process' correct spot. This ensures that processes of equal priority will be served in a round-robin fashion. Revisit the implementation of insert() to see this.

1