From owner-freebsd-alpha Mon Apr 30 14:47:16 2001 Delivered-To: freebsd-alpha@freebsd.org Received: from smtp03.primenet.com (smtp03.primenet.com [206.165.6.133]) by hub.freebsd.org (Postfix) with ESMTP id 6142237B61A for ; Mon, 30 Apr 2001 14:47:11 -0700 (PDT) (envelope-from tlambert@usr01.primenet.com) Received: (from daemon@localhost) by smtp03.primenet.com (8.9.3/8.9.3) id OAA15921; Mon, 30 Apr 2001 14:47:09 -0700 (MST) Received: from usr01.primenet.com(206.165.6.201) via SMTP by smtp03.primenet.com, id smtpdAAAtBaOdF; Mon Apr 30 14:47:01 2001 Received: (from tlambert@localhost) by usr01.primenet.com (8.8.5/8.8.5) id OAA12404; Mon, 30 Apr 2001 14:47:53 -0700 (MST) From: Terry Lambert Message-Id: <200104302147.OAA12404@usr01.primenet.com> Subject: Re: determine cycle counter frequency in user space To: neugebar@dcs.gla.ac.uk (Rolf Neugebauer) Date: Mon, 30 Apr 2001 21:47:48 +0000 (GMT) Cc: freebsd-alpha@FreeBSD.ORG In-Reply-To: from "Rolf Neugebauer" at Apr 29, 2001 04:46:24 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-alpha@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > I try to determine the cycle counter frequency from a user space > program to do some accurate time counting. Ideally, I would like to > access the rpb_cc_freq field Hardware Restart Parameter Block (rpb) as > possible under OSF/1 using getsysinfo(2) or the calibrated > cycles_per_sec variable from sys/alpha/alpha/machdep.c. > > While it would be easy to introduce a new sysctl or similar, I was > wondering if there is already a 'standard' way under FreeBSD to access > this information (ideally, also under ix86). > > I searched around a bit, but couldn't find any obvious way. The closest you will find is hw.cpu_mhz, via sysctl. I am personally not very happy at all with what has happened to the clock code; what used to be a direct reference to "curtime" is now a convoluted mess requiring a dead chicken and some pagan incantations to achieve the same thing, at the same time making gettimeofday() inordinately expensive. It also bothers me that the standard system clock doesn't use the cycle counter, and instead is rn of the i8254 interrupt, which bothers me no end. If you could get a baseline and a frequency in user space, it would be very easy to implement gettimeofday() in user space, if things were not so strange. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message