nachos.kernel.devices
Class InterruptHandler

java.lang.Object
  extended by nachos.kernel.devices.InterruptHandler
All Implemented Interfaces:
nachos.machine.InterruptHandler
Direct Known Subclasses:
AlarmTest, ConsoleTest.ConsHandler, DiskDriver.DiskIntHandler, NetworkDriver.ReceiveHandler, NetworkDriver.SendHandler, Scheduler.TimerInterruptHandler

public abstract class InterruptHandler
extends java.lang.Object
implements nachos.machine.InterruptHandler

This class controls entry to and exit from interrupt service routines. It is an abstract class which should be extended to create interrupt handlers for specific devices. Each subclass must provide an implemention for the serviceDevice() method. The main reason this class is here is to implement the yieldOnReturn() method, which provides an interrupt service routine (such as the one for the timer) the ability to request that rescheduling of the CPU take place at the completion of interrupt service.


Field Summary
private static boolean inHandler
          Are we currently running an interrupt handler?
private static boolean yieldOnReturn
          Should the CPU be rescheduled on return from the current handler?
 
Constructor Summary
InterruptHandler()
           
 
Method Summary
 void handleInterrupt()
          Handler called by the machine when any interrupt occurs.
abstract  void serviceDevice()
          Subclasses must implement this method to provide device-specific interrupt service.
static void yieldOnReturn()
          Called from within an interrupt handler, to cause a context switch (for example, on a time slice) in the interrupted thread, when the handler returns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inHandler

private static boolean inHandler
Are we currently running an interrupt handler?


yieldOnReturn

private static boolean yieldOnReturn
Should the CPU be rescheduled on return from the current handler?

Constructor Detail

InterruptHandler

public InterruptHandler()
Method Detail

handleInterrupt

public void handleInterrupt()
Handler called by the machine when any interrupt occurs.

Specified by:
handleInterrupt in interface nachos.machine.InterruptHandler

serviceDevice

public abstract void serviceDevice()
Subclasses must implement this method to provide device-specific interrupt service.


yieldOnReturn

public static void yieldOnReturn()
Called from within an interrupt handler, to cause a context switch (for example, on a time slice) in the interrupted thread, when the handler returns. We can't do the context switch right here, because that would switch out the interrupt handler, and we want to switch out the interrupted thread. Instead, we set a flag and take care of the context switch when the current handler returns.