Please enable JavaScript to view this site.

Virtual Alpha User Guide

Warning:        The Avanti clock is dependent upon the Windows clock.  Changing the Windows clock while Avanti is running has consequences.  Windows clock changes will impact Avanti's perception of time until Avanti can re-sync with Windows. In short, do not change Windows time while Avanti is running.  For more details, read on.

A legacy Alpha system uses hardware to maintain accurate time.  An Alpha emulator must achieve the same clock accuracy using software.  Doing so is not a straight forward task.

On a real AlphaServer, two mechanisms are used to keep track of time.  One is the clock interrupt, which interrupts the processor 1024 times per second, the other is the cycle counter, which is an internal processor register that increments at the rate of the processor’s clock (i.e.  100,000,000 times per second for a 100 MHz CPU).

There is no easy way to provide direct emulation of this functionality in the emulator.  Windows does not offer a method to have a program interrupted at a steady rate of 1024 times per second.  It would be feasible to have the emulator run a dedicated execution thread to generate the clock, but this would keep an additional CPU on the host system busy 100% of the time.  So, in Avanti, the clock is generated on the one host CPU that is already 100% busy, the CPU that executes the Alpha CPU emulation thread.

If the emulator were to execute Alpha instructions at a steady rate, e.g.  50 million instructions per second, providing the timing function would be easy.  The cycle counter could be incremented by 2 every instruction and trigger a clock interrupt every 48828 instructions.  However, the speed of executing Alpha instructions on the emulator varies, so a mechanism is required to stabilize the clock.  Avanti does not increment the cycle counter after every instruction, but after executing a number of instructions.  The cycle counter increment amount is variable.  When the emulator starts, it runs a short performance test to get an estimate of the host CPU’s speed and uses the result to set a reasonable default value for the cycle counter increment.

To keep the clock in sync, a second thread wakes up periodically (about 100 times per second).  When this second thread wakes up, it gets the current time from the Windows system and uses it to calculate what the value of the cycle counter, based on the current time, should be.  If it finds that the cycle counter maintained by the CPU thread is off, it will apply a correction to the cycle counter increment to either slow down or speed up the cycle counter.  This way, the cycle counter increments at a reasonably stable rate, with very little clock skew over a long period of time.

Finally, the clock interrupt is derived from the stabilized cycle counter.  The CPU thread keeps track of the cycle counter value at which the next clock interrupt should be triggered.

The emulated clock accuracy is critical to precise Alpha emulation and has been tested extensively.  Avanti exhibits no clock drift over extended run periods under varying load conditions.

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC