[ntp:questions] Re: How application get precise time from Win NT/XP system time that synchronies to NTP

Martin Burnicki martin.burnicki at meinberg.de
Tue Mar 29 10:27:51 UTC 2005


Roger,

Roger Chou wrote:
> My applications is to do time stamp that need 10 microsecond accuracy.
> Many PCs in network environment will need ssme precise time stamp. One way
> to do it is to install Trimble Acutime GPS for each PC. Because of cost
> consideration, I installed a Win NT NTP server that use Trimble Acutime
> GPS as reference clock and the rest of PCs synchronize to the server and I
> try to find a way to get precise time from NT/ XP system. I head NT/XP
> system time can only reach 10 millisecond resolution, if it is true? Or
> there is another way to do it.

The Windows API to read the system time provides a resolution of
nanoseconds. However, the value returned by those APIs is updated once
every timer tick, so if your application polls the system time
continuously, it will read the same time between two ticks, and after each
tick it will find the system time has been incremented by the tick
interval, i.e. 10 or 15 milliseconds.

In order to increase the resolution of the Windows system clock beyound that
tick interval, the NTP service under Windows runs a special high priority
thread which interpolates the time between two clock ticks using the
Windows performance counter API. Unfortunately, you are unable to access
that interpolated time from your application.

Even worse, if you start any application that uses the Windows multimedia
timer API and sets the multimedia timers to highest resolution of 1
millisecond, the normal system clock is delayed by 10 to 20 milliseconds as
long as that application is running. You can simply test it by letting NTP
adjusting your system time until synchronization has settled, then start
such an application like Quicktime, and use the ntpq command to see how the
offset suddenly changes by several milliseconds if you start Quicktime, and
the offset falls back close to the initial value if you exit Quicktime.
Note that this is _not_ a problem of Quicktime, neither of NTP, but of the
implementation of the Windows system clock, and task scheduling.

Meinberg provides GPS PCI cards which provide an API which lets your
application read time stamps with better than 1 microsecond resolution and
accuracy directly from the board. 

The API call even accounts for the latency due to the execution time of the
driver when calling the device driver to access the PCI board.

Martin
-- 
Martin Burnicki

Meinberg Funkuhren
Bad Pyrmont
Germany



More information about the questions mailing list