Deferring Clock Processing

Deferring Clock Processing

There are some situations in which we really do not want to switch off interrupts for any period of time, even a short one. An example of this is when we are receiving a block of input from a very fast programmed I/O device such as a network or disk device. Here, the CPU is involved in transferring data from the device and must be available immediately upon interrupt. Otherwise the device will overrun and data will be lost. The problem is that it is difficult to guarantee that interrupts will never be switched off because a context switch can happen at any time - and the context switch would disable interrupts causing lost data.

The solution in XINU is to

  1. run a process which will not initiate a context switch (the null process is chosen for this and is made to run by temporarily giving it the highest priority)
  2. defer the processing of clock interrupts - this ensures that a context switch (resched) will not be initiated because a sleeping process is awakened.

While XINU defers clock processing, it does not ignore clock interrupts entirely. Instead it counts them up. When deferred processing is turned off, XINU "catches up" by waking any sleeping processes that should have been woken during the deferral period, and by causing a context switch if the time quantum for the running process has expired. The two routines that put XINU into and out of defer mode are stopclk() and strtclk() respectively.

1