Re: Delay in milliseconds and need info abt Multimedia timers

Tech-Archive recommends: Fix windows errors by optimizing your registry



Mahesh BS wrote:
Thankyou for the reply.

Sorry. I was looking out for delay in microseconds.
Do you have any idea?

Read my response again.

Tom


Regards,
Mahesh

"Tom Widmer [VC++ MVP]" <tom_usenet@xxxxxxxxxxx> wrote in message
news:OFvTYh3mGHA.1204@xxxxxxxxxxxxxxxxxxxxxxx

Mahesh BS wrote:

Hello,

I am trying to develop application which needs some delay to be
introduced. Here I need to introduce a delay of few micro seconds. Using
Multimedia timers I could get a lowest delay of up to 1 ms.

1) Can anybody help me in knowing how can we achieve a delay of few
millseconds on VC++.

Which is it, microseconds or milliseconds?


2) Does anybody have an idea about the accuracy of the multimedia

timers.

If you call timeBeginPeriod(1), you get 1ms roughly (wakeups on the
whole will be between 0 and 1ms late), and that's the best blocking wait
accuracy available on Win32.

If you need a delay of a few microseconds, a non-blocking busy wait
using QueryPerformanceCounter is the way to go, making sure your process
priority class is set to REALTIME_PRIORITY_CLASS.

Note that it is hard to guarantee any particular accuracy on Windows
since it isn't a realtime system, but you should be able to get good
"average" scheduling.

Tom



.



Relevant Pages

  • Re: Kernel mode programming in VC++
    ... invalid premise that you can reprogram the timer chip. ... You'd have a delay measured in hundreds of milliseconds! ... but since it takes an unpredictable number of microseconds to get ... jmp short $+2 ...
    (microsoft.public.vc.mfc)
  • Re: [PATCH 3/3] delay: add generic udelay(), mdelay() and ssleep()
    ... So __const_udelay(x) doesn not delay for x microseconds. ... not sligntly slower as you seem to think. ... So, to reiterate, optimizing udelayfor speed makes no sense. ...
    (Linux-Kernel)
  • Re: Timer with Micro seconds
    ... thig is when i am trying to get microseconds delay with this code, ... letting other threads wiht lower priorities to run and using your ... consume more power (because your CPU can't get in idle mode etc.). ... thread priority if you need an exact delay and using SleepTillTick to ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Delay in milliseconds and need info abt Multimedia timers
    ... Mahesh BS wrote: ... I was looking out for delay in microseconds. ... using QueryPerformanceCounter is the way to go, ...
    (microsoft.public.vc.stl)
  • Re: Delay in milliseconds and need info abt Multimedia timers
    ... I was looking out for delay in microseconds. ... If you need a delay of a few microseconds, a non-blocking busy wait ... using QueryPerformanceCounter is the way to go, ...
    (microsoft.public.vc.stl)