Re: Waitable timer accuracy

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

From: William DePalo [MVP VC++] (willd.no.spam_at_mvps.org)
Date: 04/20/04


Date: Mon, 19 Apr 2004 20:34:08 -0400


"Revelation" <anonymous@discussions.microsoft.com> wrote in message
news:33B59E91-91D8-4B4A-BC94-6B5A8D3A0CEA@microsoft.com...
> After much frustration I tracked down the cause to
> be the waitable timer losing accuracy. When working normally,
> the timer is able to produce delays down to 1 millisecond, but
> when the behaviour starts to get eratic it appears that the timers
> minimum delay drops to 1 hundreth of a second. Now I know that
> the documentation states the accuracy of the timer is system
> dependant, but my system is clearly capable of 1ms delays when
> it chooses.

Excluding the CE variants, no operating system on which Win32 runs can be
classified as "real-time" with hard guarantees as to responsiveness and
latency. Could the behavior you see not be due to the timer per se but
rather what all else is happening contemporaneously in the system?

That said, I think that it is wise to bracket stretches of code - (perhaps
the whole application) - between calls to

    timeBeginPeriod(1);

and

    timeEndPeriod(1);

Then you may want to consider goosing the priority of the thread(s) that
need(s) the most precise timer.

Next, it would be hard to make definitive statements about where the bottle
neck(s) lie(s) so you probably need to find a good profiler. I think Intel
may have one but I don't have any experience with it.

Finally, wondering aloud, "is it the GC who is doing you in?" :-)

Regards,
Will



Relevant Pages

  • Re: Time accuracy
    ... WarpVision isn't using the hires timer". ... thread 1 and perform some benchmark counting in thread 2, or is there another way to get delays smaller than DosSleep's lores delays? ... Create the necessary semaphore and data structures ... For anything requiring more than 15 frames per second of animation, the only way to do it reliably on nearly all versions of OS/2 is to interface with the TIMER0 device driver. ...
    (comp.os.os2.programmer.misc)
  • Re: sampling rate problem
    ... thread's data will be accessible to this thread unless you syncronize. ... Since it is unlikely that you will ever get exact timing from sleep or timer ... I had a similar problem getting accurate timer delays while measuring wind ...
    (comp.lang.java.programmer)
  • Re: Multithread operations
    ... Often this kind of problems are solved by simple disabling the timer at the beginning of the tick event and enable it again at the end. ... It sends the request, receives the answer and updates the controls. ... These delays are due to the send/receive/elaborate functions. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: What can be the cause of slower API execution ?
    ... |> delays on their computers. ... |>> Start = Timer ... Some Windows security settings? ...
    (microsoft.public.vb.general.discussion)
  • Re: Time accuracy
    ... WarpVision isn't using the hires timer". ... thread 1 and perform some benchmark counting in thread 2, or is there another way to get delays smaller than DosSleep's lores delays? ... A threaded application in OS/2 gets a slice every 32ms, and that makes a pretty smooth display. ... You have to work it backwards - calculate where the ball will be next assuming 32 ms have elapsed. ...
    (comp.os.os2.programmer.misc)