nachos.threads
Class Alarm
java.lang.Object
|
+--nachos.threads.Alarm
- public class Alarm
- extends Object
Uses the hardware timer to provide preemption, and to allow threads to sleep
until a certain time.
|
Constructor Summary |
Alarm()
Allocate a new Alarm. |
|
Method Summary |
void |
timerInterrupt()
The timer interrupt handler. |
void |
waitUntil(long x)
Put the current thread to sleep for at least x ticks,
waking it up in the timer interrupt handler. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Alarm
public Alarm()
- Allocate a new Alarm. Set the machine's timer interrupt handler to this
alarm's callback.
Note: Nachos will not function correctly with more than one
alarm.
timerInterrupt
public void timerInterrupt()
- The timer interrupt handler. This is called by the machine's timer
periodically (approximately every 500 clock ticks). Causes the current
thread to yield, forcing a context switch if there is another thread
that should be run.
waitUntil
public void waitUntil(long x)
- Put the current thread to sleep for at least x ticks,
waking it up in the timer interrupt handler. The thread must be
woken up (placed in the scheduler ready set) during the first timer
interrupt where
(current time) >= (WaitUntil called time)+(x)
- Parameters:
x - the minimum number of clock ticks to wait.- See Also:
Timer.getTime()