Yes, WaitForSingleObject uses timer resolution; it does not use a high resolution timer, such as QueryPerformanceCounter.
http://msdn.microsoft.com/en-us/library/ms687069(VS.85).aspx , the MSDN article in the "Waiting Functions" section applies to this:
The accuracy of the specified timeout interval depends on the resolution of the system clock. The system clock is ticking at a constant speed. If the wait interval is less than the resolution of the system clock, a timeout may wait less than the specified time period. If the wait interval exceeds one tick, but less than two, the wait may be somewhere between one and two ticks, etc.
This article also explains how to use timeBeginPeriod to increase the resolution of the system clock - but this is not recommended.
I can come up with several reasons. First, a higher resolution is not required for almost all use of WaitForSingleObject. Using a high-resolution timer will require that the kernel constantly polls the timer (not feasible, since the kernel code is not guaranteed to always work) or reprogram it frequently to generate an interrupt (since there can be several WaitForSingleObjects and most likely only one programmable interrupt )
On the other hand, there is already a synchronization source that is constantly updated with a resolution that is more than enough for WaitForSingleObject, SetWaitableTimer and Sleep.
Michael May 21 '09 at 21:31 2009-05-21 21:31
source share