Main Page | Alphabetical List | Class List | File List | Class Members | File Members

timer.h

Go to the documentation of this file.
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-1993 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 00026 // The following class defines a hardware timer. 00027 class Timer { 00028 public: 00029 Timer(VoidFunctionPtr timerHandler, int callArg, bool doRandom); 00030 // Initialize the timer, to call the interrupt 00031 // handler "timerHandler" every time slice. 00032 ~Timer() {} 00033 00034 // Internal routines to the timer emulation -- DO NOT call these 00035 00036 void TimerExpired(); // called internally when the hardware 00037 // timer generates an interrupt 00038 00039 int TimeOfNextInterrupt(); // figure out when the timer will generate 00040 // its next interrupt 00041 00042 private: 00043 bool randomize; // set if we need to use a random timeout delay 00044 VoidFunctionPtr handler; // timer interrupt handler 00045 int arg; // argument to pass to interrupt handler 00046 00047 }; 00048 00049 #endif // TIMER_H

Generated on Thu Sep 16 12:33:46 2004 for NachOS by doxygen 1.3.8