From 45609bea175fed9529ffe3e4a02aa0a51118522b Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Thu, 28 Mar 2002 16:02:44 +0000 Subject: [PATCH] Get the magnitude of the NTP adjustment right. --- sys/kern/kern_tc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 85900bd1799..e058e74151d 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -238,10 +238,11 @@ tco_setscales(struct timecounter *tc) /* * We get nanoseconds with 32 bit binary fraction and want * 64 bit binary fraction: x = a * 2^32 / 10^9 = a * 4.294967296 - * The range is +/- 500PPM so we can multiply by about 8500 - * without overflowing. 4398/1024 = is very close to ideal. + * The range is +/- 500PPM so we can only multiply by about 8500 + * without overflowing. The best suitable fraction is 4398/1024. + * Divide by 2 times 1024 to match the temporary lower precision. */ - scale += (tc->tc_adjustment * 4398) >> 10; + scale += (tc->tc_adjustment * 4398) / 2048; scale /= tc->tc_tweak->tc_frequency; tc->tc_scale = scale * 2; }