next up previous contents
Next: Address Translation Up: Nachos Machine Previous: Interrupt Management

Real-Time Clock Interrupts

Nachos provides a Timer object that simulates a real time clock, generating interrupts at regular intervals. It is implemented using the same event driven interrupt mechanism described above. Timer supports the following operations:

Timer(VoidFunctionPtr timerHandler, int callArg, bool doRandom)
The Timer constructor creates a real-time clock that interrupts every TimerTicks (100) time units. When the timer goes off, the Nachos simulator invokes procedure timerHandler, passing it callArg as an argument.

To add a bit of non-determinism to the system, argument doRandom specifies that the time between interrupts should be taken from a uniform interval between 1 and tex2html_wrap_inline1013 .

The real-time clock can be used to provide preemption.

Note that starting Nachos with the ``-rs'' option creates a timer object that interrupts at random intervals and preempts the currently running thread.

Thomas Narten
Mon Feb 3 15:00:27 EST 1997