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

Alarm Class Reference

The following class defines a software alarm clock. More...

#include <alarm.h>

Inheritance diagram for Alarm::

CallBackObj List of all members.

Public Methods

 Alarm (bool doRandomYield)
 Initialize the timer, and callback to "toCall" every time slice. More...

 ~Alarm ()
void WaitUntil (int x)
 suspend execution until time > now + x. More...


Private Methods

void CallBack ()
 called when the hardware timer generates an interrupt. More...


Private Attributes

Timertimer
 the hardware timer device. More...


Detailed Description

The following class defines a software alarm clock.

Definition at line 26 of file alarm.h.


Constructor & Destructor Documentation

Alarm::Alarm ( bool doRandomYield )
 

Initialize the timer, and callback to "toCall" every time slice.

Alarm::Alarm Initialize a software alarm clock. Start up a timer device

"doRandom" -- if true, arrange for the hardware interrupts to occur at random, instead of fixed, intervals.

Definition at line 23 of file alarm.cc.

Alarm::~Alarm ( ) [inline]
 

Definition at line 30 of file alarm.h.


Member Function Documentation

void Alarm::CallBack ( ) [private, virtual]
 

called when the hardware timer generates an interrupt.

Alarm::CallBack Software interrupt handler for the timer device. The timer device is set up to interrupt the CPU periodically (once every TimerTicks). This routine is called each time there is a timer interrupt, with interrupts disabled.

Note that instead of calling Yield() directly (which would suspend the interrupt handler, not the interrupted thread which is what we wanted to context switch), we set a flag so that once the interrupt handler is done, it will appear as if the interrupted thread called Yield at the point it is was interrupted.

For now, just provide time-slicing. Only need to time slice if we're currently running something (in other words, not idle). Also, to keep from looping forever, we check if there's nothing on the ready list, and there are no other pending interrupts. In this case, we can safely halt.

Reimplemented from CallBackObj.

Definition at line 50 of file alarm.cc.

void Alarm::WaitUntil ( int x )
 

suspend execution until time > now + x.


Member Data Documentation

Timer * Alarm::timer [private]
 

the hardware timer device.

Definition at line 35 of file alarm.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