Use better scaling factor for NTPs correction.

Explain the magic.
This commit is contained in:
Poul-Henning Kamp 2002-02-22 12:59:20 +00:00
parent 6e47a4f646
commit 4e2befc031
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=91065

View File

@ -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;
}