From 6b47f7b960f79159e3b327711a275c2eedbc2ba7 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 11 Apr 2012 00:42:54 +0200 Subject: [PATCH] PEP 418: Add info about sleep/suspend --- pep-0418.txt | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/pep-0418.txt b/pep-0418.txt index 9a7ed2bc1..9800627fc 100644 --- a/pep-0418.txt +++ b/pep-0418.txt @@ -307,18 +307,18 @@ Operating system clocks Monotonic clocks ---------------- -========================= =============== ================ ==================== -Name Resolution Adjusted by NTP? Action on suspend -========================= =============== ================ ==================== -CLOCK_MONOTONIC_RAW 1 ns No Stopped -gethrtime 1 ns No Not stopped -CLOCK_HIGHRES 1 ns No ? -CLOCK_MONOTONIC 1 ns Slewed on Linux Stopped on Linux -mach_absolute_time() 1 ns No ? -QueryPerformanceCounter() \- No Accuracy issue -GetTickCount[64]() 1 ms No Include suspend time -timeGetTime() 1 ms No ? -========================= =============== ================ ==================== +========================= ========== =============== ============= =============== +Name Resolution Adjusted Include sleep Include suspend +========================= ========== =============== ============= =============== +gethrtime 1 ns No Yes Yes +CLOCK_HIGHRES 1 ns No Yes ? +CLOCK_MONOTONIC 1 ns Slewed on Linux Yes No +CLOCK_MONOTONIC_RAW 1 ns No Yes No +mach_absolute_time() 1 ns No ? ? +QueryPerformanceCounter() \- No Yes ? +GetTickCount[64]() 1 ms No Yes Yes +timeGetTime() 1 ms No Yes ? +========================= ========== =============== ============= =============== Examples of clock accuracy on x86_64: @@ -515,6 +515,9 @@ The return type of timeGetTime() is a 32-bit unsigned integer. As GetTickCount(), timeGetTime() rolls over after 2^32 milliseconds (49.7 days). +The elapsed time retrieved by timeGetTime() includes time the system spends in +sleep. + The default precision of the timeGetTime function can be five milliseconds or more, depending on the machine. @@ -805,6 +808,8 @@ Sleep, suspend and monotonic time Linux ----- +sleep() is not affected by system clock update. + On Linux, CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW includes time the system spends in sleep; but it does not include time spent in hibernation (ACPI S3 mode). If the system clock jumps backward, CLOCK_MONOTONIC and @@ -815,6 +820,18 @@ CLOCK_BOOTTIME is idential to CLOCK_MONOTONIC, except it also includes any time spent in suspend. Read also `Waking systems from suspend `_ (March, 2011). +Other operating systems +----------------------- + +On Windows, GetTickCount() and GetTickCount64() include time the system +spends in sleep; sleep() is not affected by system clock update. + +On FreeBSD 8, CLOCK_MONOTONIC include time the system spends in sleep; sleep() +is not affected by system clock update. + +On OpenIndiana, CLOCK_MONOTONIC include time the system spends in sleep; +sleep() is not affected by system clock update. + Sleeping ========