Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Apr 1998 23:06:05 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, phk@critter.freebsd.dk
Cc:        peter@netplex.com.au, smp@FreeBSD.ORG
Subject:   Re: more SMP stuff
Message-ID:  <199804051306.XAA05313@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>>The scaling needs to be more robust since the h/w counter might be
>>slower than 10^6 hz.
>
>No, that is a design decision.  Timecounter must be >= 1MHz.

Why?  The i8254 is only marginally faster than 1MHz.  There's no
reason to expect a faster clock unless the CPU clock can be read.

>>>This isn't it anyway, the dummy counter is only used by syscons 
>>>screensaver calls to getmicroruntime();
>>
>>It's used by my version of the floppy driver which calls microtime()
>>to timestamp certain events.
>
>before the i8254 is initialized ?

In fdprobe(), before the i8254 is completely initialized.

>>I don't think I call nanotime() so early.  My rtcintr() calls
>>nanotime() to gather statistics, and nanotime() was reentered.
>>I don't see any reentrancy problems.  There will be one when
>>nanotime updates tc->nanotime like it should.
>
>No it shouldn't, I'm sorry but I cannot find a way where that makes
>fewer problems than it fixes...

It is essential for POSIX.1 conformance and probably for `make' E.g.,
the following shows chmod()+stat() sometimes updating the ctime of
a fifo apparently-before either is called.  (POSIX.1 doesn't have
gettimeofday(); this example uses it just to find a bad time and to
show how close to the bad time we managed to do the chmod().  argv[1]
can be set to a small integer to manually search for the window of
bad times.)

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

int
main(int argc, char **argv)
{
	unsigned delay;
	int try;
	struct stat sb;
	struct timeval tv0, tv1, tv2;

	unlink("f");
	mkfifo("f", 0777);
	delay = argc <= 1 ? 0 : atoi(argv[1]);
	for (try = 0;; try++) {
		gettimeofday(&tv0, 0);
		while (1) {
			gettimeofday(&tv1, 0);
			if (tv1.tv_sec != tv0.tv_sec)
				break;
		}
		if (delay != 0) {
			while (--delay != 0)
				;
			gettimeofday(&tv1, 0);
		}
		chmod("f", 0777);
		stat("f", &sb);
		gettimeofday(&tv2, 0);
		if (tv1.tv_sec > sb.st_ctime || tv2.tv_sec < sb.st_ctime)
			break;
	}
	printf("%d: %ld.%06ld %ld %ld.%06ld\n",
	    try, tv1.tv_sec, tv1.tv_usec, sb.st_ctime, tv2.tv_sec, tv2.tv_usec);
}
---

Bruce

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message



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