Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Interrupt Class Reference

The following class defines the data structures for the simulation of hardware interrupts. We record whether interrupts are enabled or disabled, and any hardware interrupts that are scheduled to occur in the future. More...

#include <interrupt.h>

List of all members.

Public Methods

 Interrupt ()
 initialize the interrupt simulation. More...

 ~Interrupt ()
 de-allocate data structures. More...

IntStatus SetLevel (IntStatus level)
 Disable or enable interrupts and return previous setting. More...

void Enable ()
 Enable interrupts. More...

IntStatus getLevel ()
 Return whether interrupts are enabled or disabled. More...

void Idle ()
 The ready queue is empty, roll simulated time forward until the next interrupt. More...

void Halt ()
 quit and print out stats. More...

void YieldOnReturn ()
 cause a context switch on return from an interrupt handler. More...

MachineStatus getStatus ()
void setStatus (MachineStatus st)
 idle, kernel, user. More...

bool AnyFutureInterrupts ()
 are any interrupts scheduled? More...

void DumpState ()
 Print interrupt state. More...

void Schedule (CallBackObj *callTo, int when, IntType type)
 Schedule an interrupt to occur at time "when". This is called by the hardware device simulators. More...

void OneTick ()

Private Methods

bool CheckIfDue (bool advanceClock)
 Check if any interrupts are supposed to occur now, and if so, do them. More...

void ChangeLevel (IntStatus old, IntStatus now)
 SetLevel, without advancing the simulated time. More...


Private Attributes

IntStatus level
 are interrupts enabled or disabled? More...

SortedList<PendingInterrupt *>* pending
 the list of interrupts scheduled to occur in the future. More...

bool inHandler
 TRUE if we are running an interrupt handler. More...

bool yieldOnReturn
 TRUE if we are to context switch on return from the interrupt handler. More...

MachineStatus status
 idle, kernel mode, user mode. More...


Detailed Description

The following class defines the data structures for the simulation of hardware interrupts. We record whether interrupts are enabled or disabled, and any hardware interrupts that are scheduled to occur in the future.

Definition at line 78 of file interrupt.h.


Constructor & Destructor Documentation

Interrupt::Interrupt ( )
 

initialize the interrupt simulation.

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

Interrupts start disabled, with no interrupts pending, etc.

Definition at line 74 of file interrupt.cc.

Interrupt::~Interrupt ( )
 

de-allocate data structures.


Member Function Documentation

bool Interrupt::AnyFutureInterrupts ( ) [inline]
 

are any interrupts scheduled?

Definition at line 106 of file interrupt.h.

Referenced by Alarm::CallBack().

void Interrupt::ChangeLevel ( IntStatus old,
IntStatus now ) [private]
 

SetLevel, without advancing the simulated time.

Interrupt::~Interrupt De-allocate the data structures needed by the interrupt simulation.

Interrupt::~Interrupt() { while (!pending->IsEmpty()) { delete pending->RemoveFront(); } delete pending; }

/*! Interrupt::ChangeLevel Change interrupts to be enabled or disabled, without advancing the simulated time (normally, enabling interrupts advances the time).

Used internally.

"old" -- the old interrupt status "now" -- the new interrupt status

Definition at line 108 of file interrupt.cc.

bool Interrupt::CheckIfDue ( bool advanceClock ) [private]
 

Check if any interrupts are supposed to occur now, and if so, do them.

Interrupt::CheckIfDue Check if any interrupts are scheduled to occur, and if so, fire them off.

Returns: TRUE, if we fired off any interrupt handlers Params: "advanceClock" -- if TRUE, there is nothing in the ready queue, so we should simply advance the clock to when the next pending interrupt would occur (if any).

Definition at line 284 of file interrupt.cc.

void Interrupt::DumpState ( )
 

Print interrupt state.

DumpState Print the complete interrupt state - the status, and all interrupts that are scheduled to occur in the future.

Definition at line 346 of file interrupt.cc.

void Interrupt::Enable ( ) [inline]
 

Enable interrupts.

Definition at line 87 of file interrupt.h.

Referenced by ThreadedKernel::Initialize().

void Interrupt::Halt ( )
 

quit and print out stats.

Interrupt::Halt Shut down Nachos cleanly, printing out performance statistics.

Definition at line 237 of file interrupt.cc.

void Interrupt::Idle ( )
 

The ready queue is empty, roll simulated time forward until the next interrupt.

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.

Definition at line 210 of file interrupt.cc.

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

Definition at line 150 of file interrupt.cc.

void Interrupt::Schedule ( CallBackObj * callTo,
int when,
IntType type )
 

Schedule an interrupt to occur at time "when". This is called by the hardware device simulators.

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.

"toCall" is the object to call when the interrupt occurs "fromNow" is how far in the future (in simulated time) the interrupt is to occur "type" is the hardware device that generated the interrupt

Definition at line 260 of file interrupt.cc.

IntStatus Interrupt::SetLevel ( IntStatus level )
 

Disable or enable interrupts and return previous setting.

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

Returns: The old interrupt status. Parameters: "now" -- the new interrupt status

Definition at line 126 of file interrupt.cc.

Referenced by Enable(), Thread::Fork(), Semaphore::P(), and Semaphore::V().

void Interrupt::YieldOnReturn ( )
 

cause a context switch on return from an interrupt handler.

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.

Definition at line 192 of file interrupt.cc.

Referenced by Alarm::CallBack().

IntStatus Interrupt::getLevel ( ) [inline]
 

Return whether interrupts are enabled or disabled.

Definition at line 89 of file interrupt.h.

Referenced by Thread::Sleep().

MachineStatus Interrupt::getStatus ( ) [inline]
 

Definition at line 102 of file interrupt.h.

Referenced by Alarm::CallBack().

void Interrupt::setStatus ( MachineStatus st ) [inline]
 

idle, kernel, user.

Definition at line 103 of file interrupt.h.


Member Data Documentation

bool Interrupt::inHandler [private]
 

TRUE if we are running an interrupt handler.

Definition at line 129 of file interrupt.h.

IntStatus Interrupt::level [private]
 

are interrupts enabled or disabled?

Definition at line 125 of file interrupt.h.

SortedList< PendingInterrupt *> * Interrupt::pending<PendingInterrupt *> [private]
 

the list of interrupts scheduled to occur in the future.

Definition at line 127 of file interrupt.h.

MachineStatus Interrupt::status [private]
 

idle, kernel mode, user mode.

Definition at line 132 of file interrupt.h.

bool Interrupt::yieldOnReturn [private]
 

TRUE if we are to context switch on return from the interrupt handler.

Definition at line 130 of file interrupt.h.


The documentation for this class was generated from the following files:
Generated at Wed Jul 4 11:32:23 2001 for Nachos by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001