[Python-checkins] peps: PEP 418: Add a "Hardware clocks" section

victor.stinner python-checkins at python.org
Sun Apr 1 04:24:04 CEST 2012


http://hg.python.org/peps/rev/7010ff8e845d
changeset:   4182:7010ff8e845d
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Sun Apr 01 04:03:15 2012 +0200
summary:
  PEP 418: Add a "Hardware clocks" section

 * Mention the QueryPerformanceCounter() issue on CPU with variable frequency

files:
  pep-0418.txt |  46 +++++++++++++++++++++++++++++++++++----
  1 files changed, 41 insertions(+), 5 deletions(-)


diff --git a/pep-0418.txt b/pep-0418.txt
--- a/pep-0418.txt
+++ b/pep-0418.txt
@@ -209,8 +209,30 @@
     highres.use_monotonic = hasattr(time, 'monotonic')
 
 
-Clocks
-======
+Hardware clocks
+===============
+
+* HPET: An HPET chip consists of a 64-bit up-counter (main counter)
+  counting at least at 10 MHz and a set of up to 256 comparators (at
+  least 3).  Each HPET can have up to 32 timers.
+* TSC (Time Stamp Counter): Historically, the TSC increased with every internal
+  processor clock cycle, but now the rate is usually constant (even if the
+  processor changes frequency) and usually equals the maximum processor
+  frequency. The instructor RDTSC can be used to read this counter.
+* ACPI PMTMR (power management timer): ACPI 24-bit timer with a frequency
+  of 3.5 MHz (3,579,545 Hz). HPET can cause around 3 seconds of drift per day.
+* Cyclone: The Cyclone timer uses a 32-bit counter on IBM Extended
+  X-Architecture (EXA) chipsets which include computers that use the
+  IBM "Summit" series chipsets (ex: x440).  This is available in IA32
+  and IA64 architectures.
+* PIT (programmable interrupt timer): Intel 8253/8254 chipsets with a
+  configurable frequency in range 18.2 Hz - 1.2 MHz. It is a 16-bit counter.
+* RTC (Real-time clock). Most RTCs use a crystal oscillator with a frequency of
+  32,768 Hz
+
+
+Operating system clocks
+=======================
 
 Monotonic clocks
 ----------------
@@ -363,6 +385,8 @@
 * Windows XP had a bug (see `KB896256`_): on a multiprocessor
   computer, QueryPerformanceCounter() returned a different value for
   each processor.  The bug was fixed in Windows XP SP2.
+* Issues with processor with variable frequency: the frequency is changed
+  depending on the workload to reduce memory consumption.
 
 .. _KB896256: http://support.microsoft.com/?id=896256
 .. _KB274323: http://support.microsoft.com/?id=274323
@@ -390,6 +414,11 @@
 There are applications using this undocumented function, example:
 `Timer Resolution <http://www.lucashale.com/timer-resolution/>`_.
 
+WaitForSingleObject() use the same timer than GetTickCount() with the same
+resolution.
+
+GetTickCount() has an accuracy of 55 ms on Windows 9x.
+
 
 Windows: timeGetTime
 ^^^^^^^^^^^^^^^^^^^^
@@ -610,19 +639,25 @@
 Alternatives: API design
 ========================
 
-Name of the "monotonic or fallback" function name
--------------------------------------------------
+Other names for new functions
+-----------------------------
 
-Other names were proposed:
+time.highres():
 
 * time.hires(): "hires" can be read as "to hire" as in "he hires a car
   to go on holiday", rather than a "HIgh-RESolution clock".
+* time.timer(): "it would be too easy to confuse with (or misspell as)
+  time.time()"
+
+time.monotonic():
+
 * time.steady(): no OS provides a clock advancing at a steady rate, so
   "steady" should be avoided.
 * time.try_monotonic(): it is a clear and obvious solution for the
   use-case of "I prefer the monotonic clock, if it is available,
   otherwise I'll take my chances with a best-effect clock."
-* time.wallclock()
+* time.wallclock(): it is not the system time aka the "wall clock", but
+  a monotonic clock with an unspecified starting point
 
 
 One function, no flag

-- 
Repository URL: http://hg.python.org/peps


More information about the Python-checkins mailing list