timer.h

来自「Nachos platform for Ubuntu」· C头文件 代码 · 共 50 行

H
50
字号
// timer.h //	Data structures to emulate a hardware timer.////	A hardware timer generates a CPU interrupt every X milliseconds.//	This means it can be used for implementing time-slicing, or for//	having a thread go to sleep for a specific period of time. ////	We emulate a hardware timer by scheduling an interrupt to occur//	every time stats->totalTicks has increased by TimerTicks.////	In order to introduce some randomness into time-slicing, if "doRandom"//	is set, then the interrupt comes after a random number of ticks.////  DO NOT CHANGE -- part of the machine emulation//// Copyright (c) 1992-1993 The Regents of the University of California.// All rights reserved.  See copyright.h for copyright notice and limitation // of liability and disclaimer of warranty provisions.#ifndef TIMER_H#define TIMER_H#include "copyright.h"#include "utility.h"// The following class defines a hardware timer. class Timer {  public:    Timer(VoidFunctionPtr timerHandler, int callArg, bool doRandom);				// Initialize the timer, to call the interrupt				// handler "timerHandler" every time slice.    ~Timer() {}// Internal routines to the timer emulation -- DO NOT call these    void TimerExpired();	// called internally when the hardware				// timer generates an interrupt    int TimeOfNextInterrupt();  // figure out when the timer will generate				// its next interrupt   private:    bool randomize;		// set if we need to use a random timeout delay    VoidFunctionPtr handler;	// timer interrupt handler     int arg;			// argument to pass to interrupt handler};#endif // TIMER_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?