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).
Avanti performs the timing work in the Alpha CPU emulation thread rather than dedicating another host CPU to a continuously running clock thread.
When the CPU thread starts, it samples the resolution of the Windows system clock and calibrates initial instruction-batch and timer-increment values. During execution it advances an internal timeline with instruction batches, samples Windows system time after bounded batches, and adjusts further advancement when that timeline falls outside the sampled window. When the emulated cycle counter is enabled, Avanti derives its increments from that internal timeline.
The CPU thread also records the internal time for the next periodic interrupt. The implementation advances that deadline at a nominal 1024 Hz rate and requests an interrupt when the internal timeline passes it.
This design continually relates emulated time to the Windows civil clock, but it does not guarantee zero drift on every host, workload, or power-management configuration. No current cross-host, varying-load, long-duration benchmark establishes the former universal no-drift claim. Measure clock behavior for time-sensitive workloads on the intended host.
Warning: The Avanti clock depends on the Windows civil clock. Moving Windows time forward while Avanti is running can make the emulated timeline advance rapidly toward the new sample; moving it backward can delay further clock advancement until the sampled time catches up. Do not change Windows time while Avanti is running. Stop Avanti first, change the host time, restart Avanti, and verify guest time before resuming a time-sensitive workload. For more details, read on.