By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,885 Members | 1,499 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,885 IT Pros & Developers. It's quick & easy.

High Resolution version of Sleep() in Windows

P: n/a

Has anyone come across a way to sleep (suspend execution of current
process while releasing CPU resources in the meantime) for less than a
millisecond in Windows? I know it has been done by third parties such
as with the XBO LLADRV project, but I cannot get even enough support
from them to enable their software in my project. Ideally, I need
something like the unix usleep() function which will do a
processor-friendly sleep for some number of microseconds or
nanoseconds. The LLADRV project supposedly does this for Windows
through low-level access to the OS using their LladrvWaitPreciseTime()
function.

I am using MSVC++ .Net 2003. Thanks for any leads.

--
Michael Evans
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Michael Evans" <Mi******************@mail.codecomments.com> wrote in
message news:Mi******************@mail.codecomments.com...
Has anyone come across a way to sleep (suspend execution of current
process while releasing CPU resources in the meantime) for less than a
millisecond in Windows?


Nope.

The best you can do in an application and without specialized hardware is to
use QueryPerformanceCounter() and QueryPerformanceFrequency() to poll the
counter while spinning a busy loop. But that would not "release CPU
resources in the meantime" as you put it.

Regards,
Will

Nov 17 '05 #2

P: n/a
Use SetTimer(...)/OnTimer(...)

"Michael Evans" wrote:

Has anyone come across a way to sleep (suspend execution of current
process while releasing CPU resources in the meantime) for less than a
millisecond in Windows? I know it has been done by third parties such
as with the XBO LLADRV project, but I cannot get even enough support
from them to enable their software in my project. Ideally, I need
something like the unix usleep() function which will do a
processor-friendly sleep for some number of microseconds or
nanoseconds. The LLADRV project supposedly does this for Windows
through low-level access to the OS using their LladrvWaitPreciseTime()
function.

I am using MSVC++ .Net 2003. Thanks for any leads.

--
Michael Evans
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 17 '05 #3

P: n/a
"in**@u-s-tech.com" <in***********@discussions.microsoft.com> wrote in
message news:42**********************************@microsof t.com...
Use SetTimer(...)/OnTimer(...)


The OP's requirement was a preiod "less than a millisecond". And further, as
a concession to the prehistoric versions of Windows, the dispatching of
WM_TIMER messages that are synthesized in response to SetTimer() is deferred
until there is almost nothing else in the queue.

In short, SetTimer() is almost never the right choice.

Regards,
Will
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.