Page principale | Hiérarchie des classes | Liste des classes | Répertoires | Liste des fichiers | Membres de classe | Membres de fichier

timer.h

Aller à la documentation de ce fichier.
00001 // timer.h 
00002 //      Data structures to emulate a hardware timer.
00003 //
00004 //      A hardware timer generates a CPU interrupt every X milliseconds.
00005 //      This means it can be used for implementing time-slicing, or for
00006 //      having a thread go to sleep for a specific period of time. 
00007 //
00008 //      We emulate a hardware timer by scheduling an interrupt to occur
00009 //      every time stats->totalTicks has increased by TimerTicks.
00010 //
00011 //      In order to introduce some randomness into time-slicing, if "doRandom"
00012 //      is set, then the interrupt comes after a random number of ticks.
00013 //
00014 //  DO NOT CHANGE -- part of the machine emulation
00015 //
00016 // Copyright (c) 1992-1996 The Regents of the University of California.
00017 // All rights reserved.  See copyright.h for copyright notice and limitation 
00018 // of liability and disclaimer of warranty provisions.
00019 
00020 #ifndef TIMER_H
00021 #define TIMER_H
00022 
00023 #include "copyright.h"
00024 #include "utility.h"
00025 #include "callback.h"
00026 
00027 // The following class defines a hardware timer. 
00028 class Timer : public CallBackObj {
00029   public:
00030     Timer(bool doRandom, CallBackObj *toCall);
00031                                 // Initialize the timer, and callback to "toCall"
00032                                 // every time slice.
00033     virtual ~Timer() {}
00034     
00035     void Disable() { disable = TRUE; }
00036                                 // Turn timer device off, so it doesn't
00037                                 // generate any more interrupts.
00038 
00039   private:
00040     bool randomize;             // set if we need to use a random timeout delay
00041     CallBackObj *callPeriodically; // call this every TimerTicks time units 
00042     bool disable;               // turn off the timer device after next
00043                                 // interrupt.
00044     
00045     void CallBack();            // called internally when the hardware
00046                                 // timer generates an interrupt
00047 
00048     void SetInterrupt();        // cause an interrupt to occur in the
00049                                 // the future after a fixed or random
00050                                 // delay
00051 };
00052 
00053 #endif // TIMER_H

Généré le Sun Jan 15 00:44:24 2006 pour Architecture Cible de NachOS : par  doxygen 1.4.4