parreg

To all,

Is there a way to increase the resolution of the sleep function below what seems to be 20 msec limit. Is it possible to get resolution below 1 msec in Visual C++ Or is there a work around Thanks.



Re: Visual C++ General Sleep Function Resolution

rtpninja

No, there's latency built in to all the Win32 timer/sleep functions.

You can try using a multimedia timer, but in my experience, and no matter what MS likes to say, Windows is a high-latency OS. I highly doubt you can get < 1 MS resolution reliably without dedicated hardware.

It's the reason why all the best audio/video suites (ProTools, etc) were initially debuted on the Mac. Only as hardware got faster did comparable programs start to appear on Windows.

Please don't be fooled by the hype. Windows is not a real-time OS. And was not intended to be. And can't be backfilled to be made to be.

Hope this helps.

James





Re: Visual C++ General Sleep Function Resolution

einaros

rtpninja wrote:

No, there's latency built in to all the Win32 timer/sleep functions.


Well it's not as much a latency issue as an effect of how time slices are divided between threads. When you call a function such as Sleep, the thread will typically yield its execution to the system or other threads. Even though the sleep itself isn't more than one millisecond, the thread will not be given new execution time until the next time the system clock ticks. Depending on the Windows version, the tick frequency can be anything from 7 to 55 milliseconds.






Re: Visual C++ General Sleep Function Resolution

parreg

Thanks,

I've pretty much come to the same conclusion. I've made my own timer using a loop and passing it a constant. But the
OS makes it somewhat jittery.




Re: Visual C++ General Sleep Function Resolution

Simple Samples

Using Waitable Timers






Re: Visual C++ General Sleep Function Resolution

einaros

Simple Samples wrote:

Using Waitable Timers



Chances are that the call itself will take more than one millisecond, so that would be futile.