Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Nov 1995 04:30:41 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, jhay@mikom.csir.co.za
Cc:        current@FreeBSD.org, wollman@lcs.mit.edu
Subject:   Re: Time problems
Message-ID:  <199511011730.EAA07621@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>OK, I did that and the 10 second delay takes about 8.5 seconds and the 100
>second delay takes about 88 seconds. Here is the first part of dmesg:

Urk.

>Now how do I go further to find out where my problem is?

Perhaps the 8254 clock is being accessed too fast.  Try adding some delays
before each inb() and outb() in clock.c:getit().  Count to 100 or so to
get at least 1 usec delay.

If pentium_mhz is set to 0, then microtime() uses essentially the same
method as DELAY().  It accesses the clock registers as fast as possible.
Errors as large as 15 in 100 might be noticeable if you run the following
program.  You will have to adjust the constants 25 and 50 (perhaps to 0
and 100) to filter out the uninteresting stuff.  Differences of < 0 or
much less than the average value mean that there is a problem.  The
program should calculate the average value to decide a good range to
filter...

---
#include <sys/time.h>
#include <stdio.h>

#define SIZE	102400
struct timeval buf[SIZE];

int main(void)
{
    int n;
    long s;
    struct timeval tv;
    struct timezone tz;

    s = gettimeofday(&tv, &tz);
    buf[0] = tv;
    printf("%ld %ld\n", buf[0].tv_sec, buf[0].tv_usec);
    for (n = 1; n < SIZE; ++n)
    {
	s = gettimeofday(&tv, &tz);
	buf[n] = tv;
    }
    for (n = 1; n < SIZE; ++n)
    {
	s = (buf[n].tv_sec - buf[n - 1].tv_sec) * 1000000
	    + buf[n].tv_usec - buf[n - 1].tv_usec;
	if (s < 25 || s > 50)
	    printf("%d %ld\n", n, s);
    }
    return 0;
}
---

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511011730.EAA07621>