[Git][NTPsec/ntpsec][master] 2 commits: ntpfrob: remove obsolete comment about struct timeval.
Gary E. Miller
gitlab at mg.gitlab.com
Tue Nov 15 02:00:03 UTC 2016
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
70c6b6cd by Gary E. Miller at 2016-11-14T17:48:43-08:00
ntpfrob: remove obsolete comment about struct timeval.
- - - - -
321a13a7 by Gary E. Miller at 2016-11-14T17:58:33-08:00
ntpfrob: stop assuming pre-2000 CPu speeds.
clock resolutions under 5 microSec are now common.
- - - - -
1 changed file:
- ntpfrob/precision.c
Changes:
=====================================
ntpfrob/precision.c
=====================================
--- a/ntpfrob/precision.c
+++ b/ntpfrob/precision.c
@@ -31,9 +31,6 @@ void precision(const iomode mode)
/* Find the resolution of the system clock by watching how the current time
* changes as we read it repeatedly.
*
- * struct timeval is only good to 1us, which may cause problems as machines
- * get faster, but until then the logic goes:
- *
* If a machine has resolution (i.e. accurate timing info) > 1us, then it will
* probably use the "unused" low order bits as a counter (to force time to be
* a strictly increaing variable), incrementing it each time any process
@@ -61,12 +58,12 @@ void precision(const iomode mode)
#define DNSECS 1000000000L
#define HUSECS (1024 * 1024)
-#define MINSTEP 5000 /* some systems increment uS on each call */
-/* Don't use "1" as some *other* process may read too*/
-/*We assume no system actually *ANSWERS* in this time*/
+#define MINSTEP 200 /* assume no system returns less than 200 nansec */
+/* Don't use "1" as some *other* process may read too */
+/* We assume no system actually *ANSWERS* in this time */
#define MAXSTEP 20000000 /* maximum clock increment (ns) */
#define MINLOOPS 5 /* minimum number of step samples */
-#define MAXLOOPS HUSECS /* Assume precision < .1s ! */
+#define MAXLOOPS (HUSECS * 1024) /* Assume precision < .1s ! */
int
default_get_resolution(void)
@@ -94,15 +91,15 @@ default_get_resolution(void)
diff = (diff *3)/2;
if (i >= MAXLOOPS) {
- fprintf(stderr,
- " (Boy this machine is fast ! %d loops without a step)\n",
- MAXLOOPS);
- diff = 1; /* No STEP, so FAST machine */
+ fprintf(stderr,
+ " (Boy this machine is fast ! %d loops without a step)\n",
+ MAXLOOPS);
+ diff = 1; /* No STEP, so FAST machine */
}
if (i == 0) {
- fprintf(stderr,
- " (The resolution is less than the time to read the clock -- Assume 1us)\n");
- diff = 1; /* time to read clock >= resolution */
+ fprintf(stderr,
+ " (The resolution is less than the time to read the clock -- Assume 1us)\n");
+ diff = 1; /* time to read clock >= resolution */
}
for (i=0, val=HUSECS; val>0; i--, val >>= 1) if (diff >= val) return i;
fprintf(stderr,
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/6209d81be9c86c8ff82c042f97561c5f8d439c5e...321a13a7e2d1f7e936857a2e6f0cc39a04b17a08
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161115/3fa7b709/attachment.html>
More information about the vc
mailing list