[LinuxPPS] nanosecond precision within reach? / Re: Recommendation & Stats & architectures

Remco den Besten besten at gmail.com
Mon Mar 17 19:33:11 CET 2008


This (below) is perfect !
Are you willing to share the non-kernel hackers your insights?

Did you use 1000 Hz als processor timer frequency for example?


> I modified kernel/time/ntp.c to use a smaller time constant and to use the 
> pps
> time stamp directly instead of the offset fed to it by ntp when the offset 
> goes
> below 50 milliseconds. The kernel time constant modification because I 
> don't
> like how badly modern linux kernels follow the pps for me and using the 
> pps
> directly was me wanting to see how hard it was to get something basic 
> working
> after staying up late Friday night catching up with this list and reading 
> this
> thread.
>
> Linuxpps uses getnstimeofday() so a nanosecond time stamp is available. I 
> found
> do_adjtimex() in kernel/time/ntp.c is given a microsecond offset. 
> Internally
> do_adjtimex() multiplies the offset by 1000 giving a nanosecond offset 
> with the
> last 3 digits 000. My approach was simple, use the pps time stamp directly 
> to
> get an offset. I now have a nanosecond offset instead of a microsecond * 
> 1000
> offset. One side effect of this is plotting the frequency vs time the 
> graph
> looks a lot smoother than what I had previously. I seem to get more 
> smaller
> changes and fewer larger changes to the frequency.
>
> What I did was rather simple and there is no filtering. At the moment only 
> the
> raw pps time stamp is used. I have the time stamp the kernel uses being
> exported via /proc. I have a script logging those time stamps. A plot of 
> the
> last 19 hours is at http://aiken.dnsalias.org/offset.png
>
> The kernel is staying within 1us of when it sees the pps. The world from 
> ntp's
> perspective can be seen at http://aiken.dnsalias.org/cgi-bin/linuxpps
>
> A bit off topic to this thread. Any one looking the my linuxpps page will 
> see a
> 5us difference between GPS_NMEA(0) and PPS(1). I wanted to know how much 
> delay
> there was from when the kernel learns of the interrupt to when the 
> linuxpps
> time stamp was taken. GPS_NMEA(0) is the linuxpps time stamp. PPS(1) is my 
> own
> time stamp taken at the start of handle_IRQ_event() in 
> kernel/irq/handle.c.
> There is a mean delay of 4.8us from when the kernel decides there is an
> interrupt and does something about it to when pps_event() gets a time 
> stamp.
> This is with a p3-600.
>
> -- 
>    James




More information about the LinuxPPS mailing list