[ntp:questions] How to control accuracy of GetSystemTimeAsFileTime?

Dave Hart davehart at gmail.com
Wed May 13 20:28:27 UTC 2009


On May 13, 8:12 pm, johum... at yahoo.com wrote:
> The theoretical precision of  GetSystemTimeAsFileTime() or equivalent
> procs is 100 nanoseconds. However my tests show the accuracy is
> minimum 1 millisecond and all updates are done in multiples of 1
> millisecond. I ran the tests on a new consumer-type PC desktop (quad
> processor)  and a new consumer-type laptop (dual processor), both with
> Vista, the test results were similar on both.
>
> Normally, the system time count is updated every 1 millisecond, but
> there are some long intervals when the system time is updated
> consistently every 16 milliseconds (one tick). I suspect it has to do
> with power management because these cases seem to happen when there is
> no input through the keyboard or mouse for extended period of time. My
> power management is configured to NEVER put processor to sleep, and I
> have not seen any other power managament parameter related to this
> issue.
>
> Does anybody know how to force the system time to be updated every 1
> millisecond? What to check for?

I've seen Vista's native clock tick at 0.5 msec, 1 msec, and 15.6
msec.  The 0.5 msec was observed on a Vista PC doing Media Center
duty.  You can force the resolution to stay at 1 msec or better by
running a program which uses timeBeginPeriod(1) at startup, such as
ntpd with -M specified on the command line.  It is probably enough to
write a one-line program to call timeBeginPeriod(1) [1] and exit, but
it may be required that the program remain running.

[1] http://msdn.microsoft.com/en-us/library/ms713413(VS.85).aspx

Cheers,
Dave Hart




More information about the questions mailing list