Eryk Sun <eryk...@gmail.com> added the comment:

> Absolute timeout using can reduce the overhead time of any variable 
> and object intialization cost before the WaitForMultipleObjects() 

Again, timer objects store the due time in interrupt time, not system time 
(i.e. InterruptTime vs SystemTime in the KUSER_SHARED_DATA record). The due 
time gets set as the current interrupt time plus a relative due time. If the 
due time is passed as absolute system time, the kernel just computes the delta 
from the current system time.

The timer object does record whether the requested due time is an absolute 
system time. This allows the kernel to recompute all absolute due times when 
the system time is changed manually. This is also the primary reason one 
wouldn't implement time.sleep() with absolute system time.

> using absolute timeout and GetSystemTimePreciseAsFileTime() can 
> improves the accuracy of the desired sleep time.

It would not improve the resolution. Timer objects are signaled when their due 
time is at or before the current interrupt time. The latter gets updated by the 
timer interrupt service routine, by default every 15.625 ms -- or at least that 
used to be the case.

The undocumented flag CREATE_WAITABLE_TIMER_HIGH_RESOLUTION creates a different 
timer type, called an "IRTimer" (implemented in Windows 8.1, but back then only 
accessible in the NT API). This timer type is based on precise interrupt time, 
which is interpolated using the performance counter. I don't know how the 
implementation of the timer interrupt has changed to support this increased 
resolution. It could be that the default 15.625 ms interrupt period is being 
simulated for compatibility with classic timers and Sleep(). I'd love for the 
CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag and the behavior of IRTimer objects 
to be documented.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue21302>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to