nachos.machine
Class Timer
java.lang.Object
|
+--nachos.machine.Timer
- public final class Timer
- extends Object
A hardware timer generates a CPU timer interrupt approximately every 500
clock ticks. This means that it can be used for implementing time-slicing,
or for having a thread go to sleep for a specific period of time.
The Timer class emulates a hardware timer by scheduling a timer
interrupt to occur every time approximately 500 clock ticks pass. There is
a small degree of randomness here, so interrupts do not occur exactly every
500 ticks.
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Timer
public Timer(Privilege privilege)
- Allocate a new timer.
- Parameters:
privilege
- encapsulates privileged access to the Nachos
machine.
setInterruptHandler
public void setInterruptHandler(Runnable handler)
- Set the callback to use as a timer interrupt handler. The timer
interrupt handler will be called approximately every 500 clock ticks.
- Parameters:
handler
- the timer interrupt handler.
getTime
public long getTime()
- Get the current time.
- Returns:
- the number of clock ticks since Nachos started.