next up previous
Next: About this document Up: No Title Previous: First Level Interrupt Handler

Dispatcher

How is control returned to the dispatcher ?

The current process continues unless one of the following occurs :

Hence, two types of events : Internal events (Sleeping Beauty - go to sleep and hope in the future a Prince Charming will wake you), or an external event - (unpredictable) occurs.

Dispatcher keeps a list of ready processes (threads) - how does it choose ?

a) Zero ready threads - just loops
b) One ready thread - easy
c) More that one thread - use a strategy (FIFO, LIFO, Priority)

A sample dispatcher :

PROCEDURE  DISPATCH

BEGIN

	If current^.state <> running OR
	    current^.priority < readyq^.priority THEN

	BEGIN /* choose new process */
	  IF current^.state = running THEN
	    BEGIN
		current^.state=ready
		schedule(current)
		 /* add current to ready queue
		    in priority order */
	    END
	  current := readyq
	  readyq := readyq^.next
        END
	load registers from PCB or stack
	put PC and PSW on stack

	return from interrupt 
	 /* loads PC and PSW from stack */

END

what should dispatcher do if there is no runnable process ?



Omer F Rana
Thu Feb 6 16:16:03 GMT 1997