[python-win32] sleep() for less than .001s?

Ray Schumacher rays at blue-cove.com
Fri Aug 4 22:01:49 CEST 2006


At 11:01 AM 8/4/2006, Tim Roberts wrote:


>What surprises you?  The Win32 Sleep() function takes integer
>milliseconds.  Thus, .00001 will round to 0, which says "give up the CPU
>only if a higher-priority task is waiting.".
>
>The default scheduling interval on your system is 16ms.  Some Windows
>systems use that, some use 10ms; it depends on the HAL.  Windows only
>checks for timer expiration when its scheduling runs, and the scheduler
>doesn't run any more often than that.  You can reduce that to 1ms by
>using timeBeginPeriod (I said timeBeginTime before; that was wrong), but
>it will cost overall system performance, because you're getting
>interrupts 16x as often.


Then, it will just have to be seen whether a faster scheduler is
worse than tying up one half of a dual core CPU with a thread just doing 
whiles and checking for messages.
A test on Win9x might be interesting too, to use its 1ms schedule.

Thanks again,
Ray 



More information about the Python-win32 mailing list