comments on adjusting the clock

Hal Murray hmurray at megapathdsl.net
Thu Sep 14 00:36:47 UTC 2017


(I'll be out for the next day or so, so don't expect prompt answers.  Sorry 
this isn't cleaner.  Gotta run.)

There may be bogus stuff in here.  Measure twice, edit once.

I think the whole doubletime_t was a wild goose chase.

The claimed reason was precision.  A double has 53 bits.  We are interrested 
in adjustments, not absolute values.  If we are taking a huge adjustment (31 
bits), that still leaves 20 bits of fractional second.  That's microseconds.  
I think that's good enough to get started.  Most adjustments are small 
fractions of a second.  If we start with 53 bits, we will be throwing away 
almost half of them when we convert to l_fp.

Is there any reason we are using doubles?  Why not l_fp?  (There may be some 
statistical math that is easier with floats.)  Maybe we could carry a 
parallel version in l_fp if we want to preserve precision.

---------

There are two modules that both adjust the system clock.
  libntp/clockwork.c and 
  libntp/systime.c

There are two ways to adjust the clock:
  adj_systime is in ./libntp/systime.c and 
  ntp_adjtime_ns is in ./libntp/clockwork.c

I haven't figured out what's going on.  It doesn't look good.

The doubletime_t stuff is only used in one of them.

All the calls to adj_systime pass in adjtime.  Why?
(I assume history that nobody has cleaned up yet.)

---------

./include/ntp_syscall.h checks STA_NANO and defines ntp_error_in_seconds
The comment mentions maxerror and esterror

It's only used in ntpd/ntp_control.c, but there it is used 5 times.
  It calls ntp_adjtime directly, under HAVE_KERNEL_PLL
  I think it could just call ntp_adjtime_ns

----------

There is some ugly stuff in start_kern_loop involving 
ntp_adjtime_error_handler

I think it's trying to make a run time test to see if ntp_adjtime actually 
works.  I'm a bit surprised there isn't a cleaner way.

--------


ntp_adjtime
ntp_error_in_seconds

libntp/systime.c          adj_systime
libntp/clockwork.c    ntp_adjtime_ns  called by ntp_loopfilter

ntp_adjtime_error_handler
  I think it's for in-kernel PLL
pll_trap




-- 
These are my opinions.  I hate spam.





More information about the devel mailing list