Sleeping for times accurat to a microsecond under NT 
Author Message
 Sleeping for times accurat to a microsecond under NT

A quick check of DejaNews didn't reveal any topics on this subject, so I'll
try my question here.  I am trying to write NT code that sleeps for a period
of time, with the period accurate to microseconds.  Clearly the function
Sleep() isn't what I want, as that is accurate only to milliseconds.  In
UNIX, I would do something like:

select(0, (fd_set*) 0, (fd_set*) 0, (fd_set*) 0, &timeout);

where timeout is of type "struct timeval", which has members "tv_sec" and
"tv_usec".  (The latter member being time in microseconds.)  However, under
NT, you can't make a select call where all three sets are NULL.  Opening a
dummy socket just to sleep seems like a very bad way to proceed.  Even if I
do this, even low level calls like _ftime() only return time within the
nearest millisecond.  (The time I wish to sleep is based on the system
time...)

So, is there a way to sleep for an accurate amount of time?  Searching
"sleep" under VC++5.0/SP3 didn't reveal anything.   I'll be happy with any
answer that's not MFC, as I'm avoiding MFC on this project.

Thanks in advance,

-Dan
------



Wed, 10 Jan 2001 03:00:00 GMT  
 Sleeping for times accurat to a microsecond under NT

Quote:

> I am trying to write NT code that sleeps for a period
>of time, with the period accurate to microseconds.  Clearly the function
>Sleep() isn't what I want, as that is accurate only to milliseconds

The only way of measuring time accurate to microsoeconds is the use of
performance counters. The problem is, they won't generate an event to
wake up a sleeping process. I don't think there's any way to do what
you want under NT.

Bob Moore [MVP]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Due to an unreasonable amount of queries, I no
longer answer unsolicited email questions. Sorry,
no exceptions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Wed, 10 Jan 2001 03:00:00 GMT  
 Sleeping for times accurat to a microsecond under NT

Quote:

>I don't think there's any way to do what
>you want under NT.

Let me qualify that - I don't think there's a way of doing it _this_
side of the kernel-user boundary. I'm not familiar with the kernel
stuff though, so maybe you should post in
microsoft.public.win32.programmer.kernel to find out what drivers can
do time-wise.

Bob Moore [MVP]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Due to an unreasonable amount of queries, I no
longer answer unsolicited email questions. Sorry,
no exceptions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Thu, 11 Jan 2001 03:00:00 GMT  
 Sleeping for times accurat to a microsecond under NT

Quote:

> So, is there a way to sleep for an accurate amount of time?

accurate? microseconds? nope


Thu, 11 Jan 2001 03:00:00 GMT  
 Sleeping for times accurat to a microsecond under NT
Take a look at Waitable Timers. A Waitable Timer is a new synchronization
object that was introduced with NT 4.0.

Quote:

>A quick check of DejaNews didn't reveal any topics on this subject, so I'll
>try my question here.  I am trying to write NT code that sleeps for a
period
>of time, with the period accurate to microseconds.
[snip]

>Thanks in advance,

>-Dan
>------




Sat, 13 Jan 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. microsecond timing delays in Visual C/C++

2. How to find currnet time in Microseconds?

3. How to get Julian time and microseconds?

4. How to get microseconds from Julian time

5. How to measure microsecond time intervals?

6. Microsecond timing accuracy

7. Time in Microseconds !!!

8. Time in Microseconds !!!

9. function for timing in microseconds?

10. <HELP> microsecond timing resolution using C.

11. microsecond timing...

12. Get current time microseconds

 

 
Powered by phpBB® Forum Software