The Resched and Ready Routines

Resched()

The XINU routine that performs the context switch is called resched(). This routine places the currently running process back on the ready queue (if it is still ready), gets the next ready process, and then calls _ctxsw to perform the context switch. There are a couple points to bring up here:

Ready()

One last bit of information about XINU scheduling is that there is a routine called ready() in XINU that other system routines can call when they want to take a process and move it to the ready queue. Ready() takes two parameters: the PID of the process to ready, and a flag that indicates whether ready() should make a call to resched().

Normally, the flag parameter indicates that a call to resched() should be made. If not, then it is possible that a ready process exists with a higher priority than the running process. However, if the system is readying a group of processes (using multiple calls to ready()), this flag allows the O/S to delay the context switch until the whole group has been placed on the ready queue.

1