|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnachos.machine.Interrupt
public final class Interrupt
The Interrupt class emulates low-level interrupt hardware. The hardware provides a method (setStatus()) to enable or disable interrupts.
In order to emulate the hardware, we need to keep track of all pending interrupts the hardware devices would cause, and when they are supposed to occur.
This module also keeps track of simulated time. Time advances only when the following occur:
As a result, unlike real hardware, interrupts (including time-slice context switches) cannot occur just anywhere in the code where interrupts are enabled, but rather only at those places in the code where simulated time advances (so that it becomes time for the hardware simulation to invoke an interrupt handler).
This means that incorrectly synchronized code may work fine on this hardware simulation (even with randomized time slices), but it wouldn't work on real hardware. But even though Nachos can't always detect when your program would fail in real life, you should still write properly synchronized code.
Constructor Summary | |
---|---|
Interrupt(Privilege privilege)
Allocate a new interrupt controller. |
Method Summary | |
---|---|
boolean |
disable()
Disable interrupts and return the old interrupt state. |
boolean |
disabled()
Tests whether interrupts are disabled. |
void |
enable()
Enable interrupts. |
boolean |
enabled()
Tests whether interrupts are enabled. |
void |
restore(boolean status)
Restore interrupts to the specified status. |
boolean |
setStatus(boolean status)
Set the interrupt status to be enabled (true) or disabled (false) and return the previous status. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Interrupt(Privilege privilege)
privilege
- encapsulates privileged access to the Nachos
machine.Method Detail |
---|
public void enable()
public boolean disable()
public void restore(boolean status)
status
- true to enable interrupts.public boolean setStatus(boolean status)
status
- true to enable interrupts.
public boolean enabled()
public boolean disabled()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |