Time runs too fast in a Windows virtual machine when the Multimedia Timer interface is used
search cancel

Time runs too fast in a Windows virtual machine when the Multimedia Timer interface is used

book

Article ID: 310309

calendar_today

Updated On:

Products

VMware VMware Desktop Hypervisor VMware vSphere ESXi

Issue/Introduction

Windows multimedia timers are a service provided by Windows operating system to applications that provides high resolution callbacks for applications. Enabling, disabling, or changing the rate of callbacks can cause Windows to change the rate of interrupts requested from the hardware timer. When Windows is using the CMOS Real Time Clock (RTC) as the timer interrupt source, the act of changing the rate of the hardware timer can cause small amounts of time to be gained. If the rate is changed frequently, an appreciable amount of time might be gained in the virtual machine.
Java applications commonly change the multimedia timer rate and might trigger the time gain issue.


Symptoms:
  • Time in the virtual machine drifts ahead of real time
  • Time is not synced
  • Virtual machine does not keep time


Resolution

When applications request a timer rate using the Windows Multimedia Timer interface, Windows changes the rate of timer interrupts generated by the hardware. The behavior of the CMOS RTC when changing the rate of timer interrupts is unspecified. When windows is using the CMOS RTC this can introduce a small error into Window's notion of time.

Affected Kernels

Versions of windows using the CMOS RTC for timekeeping interrupts. Whether Windows uses the CMOS RTC for timekeeping interrupts depends on which HAL it is using. The ACPI HALs are the ones that use the RTC. Which timers are in use can also be determined by looking at the TimeTrackerStats, which are described in Timekeeping in VMware Virtual Machines.

Solution

There are two possible solutions.
VMware recommends avoiding frequent changes to the multimedia timer period. Unfortunately this requires support from the application using the multimedia timer.
The other solution is to change the behavior of the virtual CMOS RTC to match the expectations of Windows. Starting with ESX/ESXi 3.5, the behavior of the CMOS RTC when its rate is changed now better matches the expectation of Windows.
This table provides a breakdown of the product and action to workaround the issue:

ProductAction
ESX 3.5 and laterNo action required.
ESX 3.0.3Ensure patch ESX303-200910401-BG is applied.
ESX 3.0.2Ensure patch ESX-1002087 is applied.
ESX 3.0.1Ensure patch ESX-1002082 is applied.
ESX 3.0.0Ensure patch ESX-1002081 is applied.
ESX 2.5.x and earlierUpgrade to ESX 3.0.0 or later.
Fusion 2.0 and laterNo action required.
Fusion 1.xUpgrade to Fusion 2.0 or later.
Player 2.0 and laterNo action required.
Player 1.xUpgrade to Player 2.0 or later.
Workstation 6.0 and laterNo action required.
Workstation 5.xUpgrade to Workstation 6.0 or later.

In some cases, it is possible to prevent the Windows multimedia timer interface from being used frequently. This involves not running the offending application or configuring it to not toggle the frequency of the timer. This is application specific and may not be possible. For applications using the Sun JVM, you can disable toggling of the frequency by passing '-XX:+ForceTimeHighResolution' to the JVM. The easiest way to do this is to set the _JAVA_OPTIONS environment variable.
To set the _JAVA_OPTIONS environment variable:
  1. Click Start > Settings > Control Panel > System > Advanced > Environment Variables.
  2. Click New under System Variables. The variable name is _JAVA_OPTIONS. The variable value is -XX:+ForceTimeHighResolution.
  3. Reboot the guest operating system to ensure the variable is propagated properly.


Additional Information

Another issue with similar symptoms is described in, Time in virtual machine drifts due to hardware timer drift (1006072) .

マルチメディア タイマー インターフェイスを使用すると Windows 仮想マシンの時刻が早くなる