PEP 418: More QueryPerformanceCounter bugs

This commit is contained in:
Victor Stinner 2012-03-29 01:57:15 +02:00
parent 9b27cd2bb7
commit 2e4b34df42
1 changed files with 20 additions and 11 deletions

View File

@ -237,21 +237,31 @@ Windows: QueryPerformanceCounter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
High-resolution performance counter. It is monotonic.
QueryPerformanceFrequency() gives its frequency.
QueryPerformanceFrequency() gives its frequency. Hardward clocks used
by QueryPerformanceCounter:
On Windows XP, QueryPerformanceFrequency() is the processor frequency and
QueryPerformanceCounter() is the TSC of the current processor.
The performance counter value may unexpectedly leap forward because of a
hardware bug, see the `KB274323`_.
Windows XP had a bug (see `KB896256`_): on a multiprocessor computer,
QueryPerformanceCounter() returned a different value for each processor.
* Windows XP: RDTSC instruction of Intel processors, the clock frequency is
the frequency of the processor
* Windows 2000: ACPI power management timer, frequency = 3,549,545 Hz
* Windows 95/98: 8245 PIT chipset, frequency = 1,193,181 Hz
QueryPerformanceFrequency() should only be called once: the frequency will not
change while the system is running. It fails if the installed hardware does not
support a high-resolution performance counter.
Bugs:
* The performance counter value may unexpectedly leap forward because of a
hardware bug, see the `KB274323`_.
* On VirtualBox, QueryPerformanceCounter() does not increment the high part
every time the low part overflows, see `Monotonic timers
<http://code-factor.blogspot.fr/2009/11/monotonic-timers.html>`_ (2009).
* VirtualBox had a bug in its HPET virtualized device:
QueryPerformanceCounter() did jump forward by approx. 42 seconds (`issue
#8707 <https://www.virtualbox.org/ticket/8707>`_).
* Windows XP had a bug (see `KB896256`_): on a multiprocessor computer,
QueryPerformanceCounter() returned a different value for each processor.
.. _KB896256: http://support.microsoft.com/?id=896256
.. _KB274323: http://support.microsoft.com/?id=274323
@ -434,8 +444,7 @@ static variable, it might be interesting to use this to make sure that the
values returned are indeed monotonic.
* Virtual machines provide less reliable clocks.
* QueryPerformanceCounter() has two known bugs:
`KB896256`_ (fixed) and `KB274323`_
* QueryPerformanceCounter() has known bugs (only one is not fixed yet)
Python may only workaround a specific known operating system bug: `KB274323`_
contains a code example to workaround the bug (use GetTickCount() to detect