On Sun, 2 Sep 2012, Mark Kettenis wrote:
ntp_update_second() subtracts some amount of time from adjtimedelta and
sets th->th_adjustment accordingly. However, if ntp_update_second is
called more than once in a row, only the last value of th->th_adjustment
is actually applied. Shouldn't the adjustments from all ntp_update_second
calls be added instead? I don't know how often this is actually hit in
practice, the normal case is that ntp_update_second is called only once.

No, this isn't right th_adjustment is the rate at which we speed up or
slow down the clock.  We shouldn't suddenly increase that rate just
because we lost a few clock ticks.

But then subtracting the amount from adjtimedelta seems wrong. I expect that it may confuse the ntp daemon, because adjtime() may not give the expected effect. Maybe it would be better to count the times th_adjustment is applied and subtract the actual adjusted amount from adjtimedelta after it is done, instead of subtracting the amount from adjtimedelta that hopefully will be applied if everything goes well?

Reply via email to