diff options
author | phk <phk@FreeBSD.org> | 2002-02-22 12:59:20 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-02-22 12:59:20 +0000 |
commit | 6beb5af66cdd422d033e8a94de23a35073864d0e (patch) | |
tree | 9344581ffdf56a17985a8b083ed65f0c3bfb273d /sys/kern/kern_tc.c | |
parent | 87ca6820c849da94cc5da4700f51904684fad62b (diff) | |
download | FreeBSD-src-6beb5af66cdd422d033e8a94de23a35073864d0e.zip FreeBSD-src-6beb5af66cdd422d033e8a94de23a35073864d0e.tar.gz |
Use better scaling factor for NTPs correction.
Explain the magic.
Diffstat (limited to 'sys/kern/kern_tc.c')
-rw-r--r-- | sys/kern/kern_tc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 71b9e5a..a6b300e 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -207,7 +207,13 @@ tco_setscales(struct timecounter *tc) /* Sacrifice the lower bit to the deity for code clarity */ scale = 1ULL << 63; - scale += (tc->tc_adjustment * 4295LL) / 1000LL; + /* + * 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. + */ + scale += (tc->tc_adjustment * 4398) >> 10; scale /= tc->tc_tweak->tc_frequency; tc->tc_scale = scale * 2; } |