|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnachos.machine.Timer
public class Timer
This class emulates a hardware timer device. A hardware timer generates a CPU interrupt every X ticks. This means it can be used for implementing time-slicing. In order to introduce some randomness into time-slicing, if "doRandom" is set, then the interrupt is comes after a random number of ticks.
Field Summary | |
---|---|
static int |
DefaultInterval
Default (average) time between timer interrupts, in ticks. |
int |
interval
(Average) time between timer interrupts for this timer. |
Constructor Summary | |
---|---|
Timer(java.lang.String name,
InterruptHandler handler)
Initialize a hardware timer device that will generate periodic interrupts at the default interval. |
|
Timer(java.lang.String name,
InterruptHandler handler,
boolean doRandom)
Initialize a hardware timer device that will generate periodic, possibly randomized, interrupts at a default average interval. |
|
Timer(java.lang.String name,
InterruptHandler handler,
int ticks)
Initialize a hardware timer device that will generate periodic interrupts at a specified interval. |
|
Timer(java.lang.String name,
InterruptHandler handler,
int ticks,
boolean doRandom)
Initialize a hardware timer device that will generate periodic, possibly randomized, interrupts with a specified average interval. |
Method Summary | |
---|---|
void |
cancel()
Cancel the timer object. |
void |
handleInterrupt()
Method called by the machine when an interrupt occurs. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DefaultInterval
public final int interval
Constructor Detail |
---|
public Timer(java.lang.String name, InterruptHandler handler, int ticks, boolean doRandom)
name
- The name of the timer, for debugging purposes.handler
- The interrupt handler object for the timer device.
Its handleInterrupt() method is called with interrupts disabled
every time the timer expires.doRandom
- If true, arrange for the interrupts to occur
at random, instead of fixed, intervals.ticks
- The average number of ticks between interrupts.public Timer(java.lang.String name, InterruptHandler handler, boolean doRandom)
name
- The name of the timer, for debugging purposes.handler
- The interrupt handler object for the timer device.
Its handleInterrupt() method is called with interrupts disabled
every time the timer expires.doRandom
- If true, arrange for the interrupts to occur
at random, instead of fixed, intervals.public Timer(java.lang.String name, InterruptHandler handler, int ticks)
name
- The name of the timer, for debugging purposes.handler
- The interrupt handler object for the timer device.
Its handleInterrupt() method is called with interrupts disabled
every time the timer expires.ticks
- The average number of ticks between interrupts.public Timer(java.lang.String name, InterruptHandler handler)
name
- The name of the timer, for debugging purposes.handler
- The interrupt handler object for the timer device.
Its handleInterrupt() method is called with interrupts disabled
every time the timer expires.Method Detail |
---|
public void handleInterrupt()
InterruptHandler
handleInterrupt
in interface InterruptHandler
public void cancel()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |