VirtualBox

Opened 14 years ago

Closed 8 years ago

#7609 closed defect (obsolete)

Windows XP Guest - timeBeginPeriod( ) slows system clock

Reported by: ewopost@bellsouth.net Owned by:
Component: other Version: VirtualBox 3.2.10
Keywords: Cc:
Guest type: Windows Host type: Windows

Description (last modified by aeichner)

A system service running in a Windows XP SP3 Guest can use the Windows "timeBeginPeriod( )" function to change the system time tick resolution. That is common with multimedia or real-time applications. I have such a system service.

After the service has changed the Windows XP Guest timer resolution a problem occurs when running on a Windows 7 Host. The system time in the Guest updates at a much slower rate than normal and the time in the Guest falls behind the correct time. Any time related events occur at a slower than normal rate. For example, desktop fade effects, animated mouse pointers, Task Manager refreshing, and multimedia applications all appear to be "slow" due to the system time updating at a slower rate.

When the Windows time resolution is set back to the default by the system service then the time behaves normally again. If the Windows clock is reset to the correct time then it remains correct.

The service changes the time using this code.

TIMECAPS tc;

/* Get time capabilities of system */
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
Critical( );
}
/* Set the highest possible timer resolution (1 ms. if possible) */
gwTimerRes = min(max(tc.wPeriodMin, 1), tc.wPeriodMax);
if ( timeBeginPeriod(gwTimerRes) != TIMERR_NOERROR )
{
Critical( );
}

When the service is stopped it sets the time resolution back to normal.

/* Set the timer resolution back to normal */
if ( timeEndPeriod(gwTimerRes) != TIMERR_NOERROR ) {}

Other than the system time and timers being "slow" there are no other apparent problems in the Guest OS. I did not see excessive CPU usage, I/O or Interrupt activity. Although many things appear "slow" due to the incorrect time updates the execution of CPU instructions in the Guest does not seem to be affected.

I verified that the "timeBeginPeriod( )" Windows function causes the problem to occur and that the problem stops after calling "timeEndPeriod( )". This problem might explain some of the "Slow Windows Guest" complaints that are unresolved. The curious thing about the problem is that it does not appear to happen with Linux Host OS.

I have also tested the system service on a number of real PCs in order to verify that the problem is not the system service. After only seeing the problem in a VirtualBox guest I decided to investigate the problem further. I removed code from the system service until I found the functions causing the problem.

The problem also occurs with version 3.2.8 of VirtualBox under the same conditions. The problem occurs with or without the Guest Additions installed.

Change History (5)

comment:1 by ewopost@bellsouth.net, 14 years ago

The same problem also occurs using the multimedia timer function.

ghMMTimer = timeSetEvent( 1, 0, (LPTIMECALLBACK)ghMMEvent, 0, TIME_PERIODIC | TIME_CALLBACK_EVENT_SET ) ;

The problem is related to the selected timer resolution. For example, the following 10 millisecond resolution settings do not cause the problem.

/* Get time capabilities of system */
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
Critical( );
}
/* Set the highest possible timer resolution (10 ms. if possible) */
gwTimerRes = min(max(tc.wPeriodMin, 10), tc.wPeriodMax);
if ( timeBeginPeriod(gwTimerRes) != TIMERR_NOERROR )
{
Critical( );
}
ghMMTimer = timeSetEvent( 10, 10, (LPTIMECALLBACK)ghMMEvent, 0, TIME_PERIODIC | TIME_CALLBACK_EVENT_SET ) ;

This may be a Windows problem that occurs when the hardware platform does not have enough performance to process all the multimedia timer events at the requested rate. I am running the VM on a Core i7 quad-core CPU at 3.65 GHz. and machines able to run the system service are considerably slower (Pentum III 1 Ghz.). That makes me believe that this should work in a VM. This could also be a scheduling problem in VirtualBox related to timer interrupts when the timer is reprogrammed in the virtual hardware.

comment:2 by ewopost@bellsouth.net, 14 years ago

After more testing I have verified that in my case I only see a problem when using a timer resolution of 1ms. I do not see the problem when using a timer resolution of 2ms. For now I will work around the problem using a slower timer resolution. I don't know if setting a 1ms. timer resolution is unusual or if any widely used Windows software does that.

comment:3 by Frank Mehnert, 14 years ago

I think this is a duplicate of #6842, see my last comment there (comment 17).

in reply to:  3 comment:4 by ewopost@bellsouth.net, 14 years ago

Replying to frank:

I think this is a duplicate of #6842, see my last comment there (comment 17).

I agree with you. This does appear to be a duplicate. Hopefully I provided some additional information about the conditions that cause the problem. As long as there is some open ticket covering the problem it doesn't matter to me if this one is closed or added to the other. I hope that this is eventually addressed because it prevents me from using VirtualBox to do what I need for software development. I will be happy with a work around if it isn't something that can be solved in a more general way.

comment:5 by aeichner, 8 years ago

Description: modified (diff)
Resolution: obsolete
Status: newclosed

Please reopen if still relevant with a recent VirtualBox release.

Note: See TracTickets for help on using tickets.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette