[time-nuts] measuring os latency for pps

Hal Murray hmurray at megapathdsl.net
Wed Aug 26 14:37:25 EDT 2015

> It would be interesting to hear what (if any?) real-time kernels are used on
> NTP servers and if that is one way to measure/generate 1PPS input/output. 

There are 2 ways to process PPS timing.

The traditional way is for a change on a modem control signal on a serial 
port to generate an interrupt which wakes up some user code which can then 
grab the time.  On linux, ioctl TIOCMIWAIT does that.  This path depends on 
the scheduler and load on the system and all that sort of stuff.

You can do the same sort of thing with a GPIO pin.  I don't have details 

RFC 2783 describes the way ntpd uses PPS on most OSes.  When the kernel gets an interrupt, it saves the time.  The user program can poll to get the most recent time stamp.  (The RFC describes an option to wake up a user program, but ntpd doesn't use that and most kernel's don't implement it.)

On linux, you can see that info with something like:
[murray at shuksan]$ cat /sys/devices/virtual/pps/pps0/assert
[murray at shuksan]$ 

The stuff before the # is the time stamp.  The number after the # is the PPS count.

If you know the PPS is supposed to happen at a second boundary, that will give you the offset of your clock.  If you know your clock is accurate, that will tell you when the pulse happened.

These are my opinions.  I hate spam.

More information about the time-nuts mailing list