Hello, On Monday, October 1, 2007 at 17:38:23 +0200, Alain Guibert wrote:
> We can also try to make adjtimex less sensible to system load. The > first step on this path [is commited into 1.23] Now a small second step: The first timestamp in a serie is less accurate than the following ones. The attached training-gettimeofday.patch workarounds this by sampling and discarding a first dummy timestamp. The benefit on accuracy is very variable depending on the machine: 20 µs on my slow test machine, maybe less on a fast modern PC, probably upto 200 µs on some SoCs (unconfirmed). > This also reduced a little bit the variability of measures. And > marginaly reduced the sensibility to system load. It's only a first > step, though. The same stands for the second step! ;-) > BTW I suspect that in cmos_read_time() the case where we are using > /dev/rtc but ioctl(RTC_UIE_ON) fails, just can't work: It will block > forever in read() later. Can't verify for sure, because on my machines > the ioctl(RTC_UIE_ON) succeeds. This is fixed since adjtimex 1.24, see bug #460065 Alain.
2008-07-28 Alain Guibert <[EMAIL PROTECTED]> * adjtimex.c (compare, log_times): The first call to gettimeofday() in a process takes longer than usual, and the timestamp taken is a little bit late (up to 200 microseconds). Let's consume this bad call, so that the important timestamps are all coherant at the top of accuracy. * (log_times): We don't need the kernel's internal timezone. Let's stop requesting it. Signed-off-by: Alain Guibert <[EMAIL PROTECTED]> diff -prud adjtimex-1.24.orig/adjtimex.c adjtimex-1.24/adjtimex.c --- adjtimex-1.24.orig/adjtimex.c Mon Jul 28 08:47:56 2008 +++ adjtimex-1.24/adjtimex.c Mon Jul 28 09:42:58 2008 @@ -917,6 +917,10 @@ compare() int wrote_to_log = 0; int hz, tick_min, tick_mid, tick_max; long maxfreq; + struct timeval tv_dummy; + + /* dummy training call: the next important timestamp will be more accurate */ + gettimeofday(&tv_dummy, NULL); probe_time(&hz, &tick_min, &tick_mid, &tick_max, &maxfreq); @@ -1104,17 +1108,19 @@ static void log_times() char ch, buf[64], *s; int n, ret; struct timeval tv_sys; - struct timezone tz; struct tm bdt; time_t when, tref; double ftime_ref, ftime_sys, ftime_cmos; + /* dummy training call: the next important timestamp will be more accurate */ + gettimeofday(&tv_sys, NULL); + if (watch) { while(1) { printf("Please press <enter> when you know the time of day: "); ch = getchar(); - gettimeofday(&tv_sys, &tz); + gettimeofday(&tv_sys, NULL); when = tv_sys.tv_sec; bdt = *localtime(&when); /* set default values for most fields */ strftime(buf, sizeof(buf), "%Z", &bdt); @@ -1219,7 +1225,7 @@ offset -0.013543 failntpdate("cannot understand ntpdate output"); ntpdate_okay: - gettimeofday(&tv_sys, &tz); + gettimeofday(&tv_sys, NULL); ftime_sys = tv_sys.tv_sec; /* ntpdate selects the offset from one of its samples (the one with the shortest round-trip delay?) */ @@ -1264,7 +1270,7 @@ offset -0.013543 else /* no absolute time reference */ { time_t now; - gettimeofday(&tv_sys, &tz); + gettimeofday(&tv_sys, NULL); now = (time_t)tv_sys.tv_sec; bdt = *gmtime(&now); ftime_sys = tv_sys.tv_sec + tv_sys.tv_usec*.000001;