time module precision

Bengt Richter bokr at oz.net
Sun Jan 9 16:50:51 EST 2005


On 9 Jan 2005 03:09:27 -0800, janeaustine50 at hotmail.com wrote:
[...]
>
>What I want to do is waiting(not busy-delaying) for a few tens to
>hundreds of microseconds in some threads. The closet solution I got is
>using windows QueryPerformanceCounter (in Python, time.clock) with busy
>looping checking if we have past the target time. However, that makes
>the cpu usage upto almost 100%.
>
>So the problem (waiting tens to hundreds of us without busy looping)
>still remains...
>
Microseconds is tough if you are going to give up control to a scheduling/dispatching
mechanism that works in milliseconds (e.g. 10ms normal slice on NT4), and where
badly written interrupt handling may cause significant latency hiccups. There's a reason
CD burners come with big buffers.

One question is if you are waiting for an event that causes and interrupt, or if you are guaranteeing
a delay to give something a chance to happen (e.g. like some pysical process like a sound echo)
so you can read a sensor interface at an appropriate time after starting some process,
or whether you're waiting for an event that originates in another thread running under ordinary
scheduling constraints.

If you want close time control under windows, you may have to write driver-level software
and/or raise priorities to real-time levels and make sure those things don't run very long before
blocking. I suspect that multimedia support stuff in windows might be useful for quasi-real-time
stuff, but I haven't used it. (I just seem to remember reading something about that in the MSDN docs,
but I am not sure. And too lazy to go back and look ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list