help for delay 1ms 
Author Message
 help for delay 1ms

Dear Sir:

I want to get an accurate delay time for 1ms in win32 environment. At first,
I used
Win32 API Sleep(1), but I found it delay more longer than 1ms and  shorter
than
55ms. I don't know why. Now can anyone tell me how can I get accurate delay
for 1ms?

Thanks!

cai peng
14/10

The  follow is in Chinese:

????WIN32 (95/NT)???????1ms???e3??1?WIN32 API Sleep(1),
???????a??1ms??22??55ms. ?y?95/NT1??1ms???
???????????a????2????

2??
14/10



Sun, 01 Apr 2001 03:00:00 GMT  
 help for delay 1ms

Quote:

>I want to get an accurate delay time for 1ms in win32 environment. At
first,
>I used Win32 API Sleep(1), but I found it delay more longer than 1ms
> and  shorter than 55ms. I don't know why.

Check the docs for timeBeginPeriod(). The minimum resolution for the timer
is usually much more than 1 ms.

Regards,
Will



Sun, 01 Apr 2001 03:00:00 GMT  
 help for delay 1ms

Quote:
>55ms. I don't know why. Now can anyone tell me how can I get accurate delay
>for 1ms?

I think you should look for the High-Resolution Timers in the Win32 SDK.

QueryPerformanceFrequency(...);
QueryPerformanceCounter(...);

cIAo '`' Andreas



Sun, 01 Apr 2001 03:00:00 GMT  
 help for delay 1ms
_ftime(), maybe?

--

J. Scott Sanbar
MCSE::MCP+Internet::CNE

(take away dash from return address to e-mail me)


Quote:
>Dear Sir:

>I want to get an accurate delay time for 1ms in win32 environment. At
first,
>I used
>Win32 API Sleep(1), but I found it delay more longer than 1ms and  shorter
>than
>55ms. I don't know why. Now can anyone tell me how can I get accurate delay
>for 1ms?

>Thanks!

>cai peng
>14/10

>The  follow is in Chinese:

>????WIN32 (95/NT)???????1ms???e3??1?WIN32 API Sleep(1),
>???????a??1ms??22??55ms. ?y?95/NT1??1ms???
>???????????a????2????

>2??
>14/10



Sun, 01 Apr 2001 03:00:00 GMT  
 help for delay 1ms

Quote:

>Dear Sir:

>I want to get an accurate delay time for 1ms in win32 environment. At
first,
>I used
>Win32 API Sleep(1), but I found it delay more longer than 1ms and  shorter
>than
>55ms. I don't know why. Now can anyone tell me how can I get accurate delay

Look up multimedia timers in your VC online help. I used it a long time back
and it seemed to work for me.
Prashant.


Mon, 02 Apr 2001 03:00:00 GMT  
 help for delay 1ms

Quote:

>I want to get an accurate delay time for 1ms in win32 environment. At first,
>I used Win32 API Sleep(1), but I found it delay more longer than 1ms and  shorter
>than 55ms. I don't know why. Now can anyone tell me how can I get accurate delay
>for 1ms?

Neither Win95 nor WinNT are real-time operating systems. You will
likely find a solution that _seems_ acceptable, but in real-world
operation circumstances will occur that break your code. You can look
at the performance counters (see QueryPerformanceCounter) or
multimedia timers (see timeSetEvent). But the performance counters do
not provide any event mechanism (as their name suggests, they are
simply counters - they will not call you back or assert an event), and
multimedia timers actually will provide much worse resolution than
their documented 1ms limit.

If you don't believe me, try creating a test program which uses
performance counters to measure the _actual_ delays created by
multimedia timers. The accuracy looks pretty good.... until you do
something like starting up a disk defragger. There are drivers in the
system which can disable interrupts (e.g. video drivers, atapi drivers
etc), which will nobble your attempt at accurate timing unless you can
control your system specification and operating circumstances
extremely tightly.

If neither of the above suggestions seems to fit the bill (and I
suspect they won't if you're serious about wanting an accurate delay),
then you might want to look at kernel-mode code for greater accuracy.
I can't help you with that, though there are people in
microsoft.public.win32.programmer.kernel who can.

Bob Moore [MVP]

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



Mon, 02 Apr 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. delays: creating time delays with time.h (unix c)

2. How to generate a delay which is less than 0.1ms with low CPU usage?

3. Timer mit 1ms Genauigkeit

4. Timer mit 1ms Genauigkeit

5. Timer resolution finer than 1ms?

6. How do you get sub 1ms timer resolution?

7. Please Help - 1min 40s delay when creating Google Web Service in Win Form

8. Help with Delay()

9. Help on Time Delay

10. Need help with sin delaying

11. HELP: Generating a 10 micro second delay?

12. Help needed! Borlandc delay

 

 
Powered by phpBB® Forum Software