next up previous
Next: Input/Output Up: Implementation Previous: Implementation

Clock Dispatcher

This is the routine called on each clock interrupt. We shall first look at the functions of the dispatcher and then its implementation.

Functions of the Dispatcher

The clock dispatcher provides the following functions:

conversion of clock rate to tick rate

service of preemption event scheduled for current clock tick.

service of wake-up event(s) scheduled for current tick.

deferred processing (discussed below)

Deferred Processing

Interrupts are disabled while a clock routine is manipulating global data such as the delta and ready lists.

This situation presents a problem in Xinu on LSI 11/2 since interrupts from fast communication devices cannot be serviced. As a result data can be lost.

To prevent such loss of data, the dispatcher supports deferred processing. When a clock is in the deferred mode (similar to the delay mode of the output dispatcher discussed under input/output) clock ticks are accumulated without servicing events. The dispatcher schedules these deferred events when it next goes into the normal mode. Special procedures are provided to set the mode of the dispatcher. The Xinu network routines call these procedures. They put the clock in a deferred mode at the start of the transfer of data and back into the normal mode at the end of this transfer.



Implementation

The clock dispatcher takes the following steps:

Is this the 6th interrupt? If yes go ahead, otherwise return.

Are clock interrupts deferred? If yes, increment the count of deferred clock ticks and return, otherwise go ahead.

Are there any sleeping processes (is slnempty true)? If yes process wake-up events otherwise go ahead.

Process preemption events.

Processing Wake-Up Events

Processing of wake-up events is done as follows:

The delta key stored of process at head of the delta list is decremented. Recall that the address of this key is kept in sltop.

If the key goes to zero, then this process and all other processes with a delta of 0 compared to this process are put in the ready list, and resched is called.

The variables sltop and slnempty are reevaluated.

Processing of Preemption Events

Processing of preemption events is easy.

A global variable PREEMPT keeps the number of clock ticks before the current process is to be preempted. This variable is decremented.

If the variable goes to zero, then resched is called, which reschedules and resets PREEMPT to QUANTUM-- the granularity of preemption.



next up previous
Next: Input/Output Up: Implementation Previous: Implementation



Prasun Dewan
Tue Feb 12 13:32:55 EST 2002