Re: On the sleep()
- From: hohhot <hohhot@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 3 Aug 2005 18:42:04 -0700
Thank you very much, Mr. Grier!
"*** Grier" wrote:
> Hi,
>
> You cannot use Sleep for precise timing. As Peter says, its minimum
> resolution is 1 mS (but it may cause the thread to not execute for
> considerably longer). In fact, Windows is not a real-time OS, so any
> accurate measurements are problematic.
>
> You can use the QueryPerformanceCounter API calls for somewhat more precise
> timing, but the actual precision (accuracy) will be less than the resolution
> that it or any other method provides.
>
> One thing that you must realize is that there is much more going on than the
> things that you can control. For example, in your application, the serial
> port UART FIFO can buffer up to 16 bytes before an interrupt is generated
> and processed -- so there may be that much latency involved in your
> measurement. However, it is possible for the serial data to be input by the
> serial port driver BEFORE all 16 bytes have been buffered by the UART FIFO.
> You will never know if this has or has not happened.
>
> Also, Windows is a multitasking OS. Since it isn't a real-time OS, any
> other application (and lots of Windows own operations) will take an
> indeterminate amount of time to execute.
>
> Any measurements that you attempt that require precision better than the
> basic 1 mS that most timing functions offer will be subject to hit-or-miss
> operation. That is, it may or may not work well enough. IMO, any really
> precise timing needs to be done in some purpose-built system.
>
> ***
>
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 4th
> Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
> www.mabry.com/vbpgser4 to order.
>
>
>
.
- References:
- On the sleep()
- From: hohhot
- Re: On the sleep()
- From: Peter van der Goes
- Re: On the sleep()
- From: hohhot
- Re: On the sleep()
- From: *** Grier
- On the sleep()
- Prev by Date: Re: On the sleep()
- Next by Date: RE: MS Development Environment has not been installed for the current
- Previous by thread: Re: On the sleep()
- Next by thread: Installation problem
- Index(es):