tac0S
Template Affectional Command Operating System
Public Member Functions | List of all members
Interrupt Class Reference

Public Member Functions

 Interrupt ()
 Interrupt::Interrupt Initialize the simulation of hardware device interrupts. More...
 
 ~Interrupt ()
 Interrupt::~Interrupt De-allocate the data structures needed by the interrupt simulation.
 
IntStatus SetLevel (IntStatus level)
 Interrupt::SetLevel Change interrupts to be enabled or disabled, and if interrupts are being enabled, advance simulated time by calling OneTick(). More...
 
void Enable ()
 Interrupt::Enable Turn interrupts on. Who cares what they used to be? Used in ThreadRoot, to turn interrupts on when first starting up a thread.
 
IntStatus getLevel ()
 
void Idle ()
 Interrupt::Idle Routine called when there is nothing in the ready queue. More...
 
void Halt ()
 Interrupt::Halt Shut down Nachos cleanly, printing out performance statistics.
 
void YieldOnReturn ()
 Interrupt::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. More...
 
MachineStatus getStatus ()
 
void setStatus (MachineStatus st)
 
void DumpState ()
 DumpState Print the complete interrupt state - the status, and all interrupts that are scheduled to occur in the future.
 
void Schedule (VoidFunctionPtr handler, int arg, long long when, IntType type)
 Interrupt::Schedule Arrange for the CPU to be interrupted when simulated time reaches "now + when". More...
 
void OneTick ()
 Interrupt::OneTick Advance simulated time and check if there are any pending interrupts to be called. More...
 

Constructor & Destructor Documentation

Interrupt::Interrupt ( )

Interrupt::Interrupt Initialize the simulation of hardware device interrupts.

Interrupts start disabled, with no interrupts pending, etc.

Member Function Documentation

void Interrupt::Idle ( )

Interrupt::Idle Routine called when there is nothing in the ready queue.

Since something has to be running in order to put a thread on the ready queue, the only thing to do is to advance simulated time until the next scheduled hardware interrupt.

If there are no pending interrupts, stop. There's nothing more for us to do.

void Interrupt::OneTick ( )

Interrupt::OneTick Advance simulated time and check if there are any pending interrupts to be called.

Two things can cause OneTick to be called: interrupts are re-enabled a user instruction is executed

void Interrupt::Schedule ( VoidFunctionPtr  handler,
int  arg,
long long  fromNow,
IntType  type 
)

Interrupt::Schedule Arrange for the CPU to be interrupted when simulated time reaches "now + when".

Implementation: just put it on a sorted list.

NOTE: the Nachos kernel should not call this routine directly. Instead, it is only called by the hardware device simulators.

Parameters
handleris the procedure to call when the interrupt occurs
argis the argument to pass to the procedure
fromNowis how far in the future (in simulated time) the interrupt is to occur
typeis the hardware device that generated the interrupt
IntStatus Interrupt::SetLevel ( IntStatus  now)

Interrupt::SetLevel Change interrupts to be enabled or disabled, and if interrupts are being enabled, advance simulated time by calling OneTick().

Returns:

Returns
The old interrupt status. Parameters:
Parameters
now– the new interrupt status
void Interrupt::YieldOnReturn ( )

Interrupt::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 here, because that would switch out the interrupt handler, and we want to switch out the interrupted thread.


The documentation for this class was generated from the following files: