next up previous
Next: ctxsw Up: Xinu Mechanism for Previous: Xinu Mechanism for

Ready List

The ready processes in the system are kept in a `queue' called the ready list. This list is sorted by the priority of the processes; the lowest priority process appears at the head of the list and the highest priority process is at the tail. Processes of the same priority are sorted by the order in which they are to get service. Thus when a new process is inserted, it is inserted not at the end of the list, but at a point determined by its priority. The current process is not on this list, its id is stored in a global integer variable called currpid. .ip " resched

resched is a routine that is called by the current process when rescheduling is to take place. (We shall discuss later the conditions that determine when a rescheduling takes place)

The routine does the following:

Choosing a New Process: It chooses the new process to execute based on the scheduling policy described above. Thus it looks at the process at the tail of the ready list. If the priority of this process is lower than the priority of the current process, then the current process, if it is executable, retains control of the CPU and the routine returns. (The scheduling policy dictates that a lower priority process in the ready list will be executed only if there are no higher priority processes in the list). Otherwise the process at the tail of the process is chosen as the new process and the following steps are taken.

Change of State of New Process: The new process is removed from the ready list, its state is changed from ready to current.

Allocation of Time: The new process is is allocated a time interval to execute (we shall study later how this is done). This time interval is the maximum time it will execute control before rescheduling takes place.

Change of State of Old Process: The routine resched is never called directly by the user process. It is called indirectly by some other system provided routine such as wait on a semaphore. This routine may change the state of the process. For instance wait changes the state of process to wait (as we will discuss later). At the point resched is called, the process is executable only if its state is still current. resched uses this information to determine if the old process needs to be put in the ready list. If the state is current it changes it to ready and inserts the process in front of other processes with the same priority (so that it is picked last among processes with the same priority, thus ensuring round robin scheduling among processes with the same priority), and behind processes with lower priority (so that a higher priority process is scheduled before a lower priority one). Otherwise it leaves the process untouched since some other routine took care of changing the state of the process and putting it in an appropriate list.

Call to ctxsw: Finally the routine ctxsw (discussed below) is called. This routine does work that cannot be done in a high level language (compared to assembly language) like C.


next up previous
Next: ctxsw Up: Xinu Mechanism for Previous: Xinu Mechanism for



Prasun Dewan
Fri Aug 30 20:17:18 EDT 1996