From owner-freebsd-alpha Tue May 1 2:56:42 2001 Delivered-To: freebsd-alpha@freebsd.org Received: from iona.dcs.gla.ac.uk (iona.dcs.gla.ac.uk [130.209.240.35]) by hub.freebsd.org (Postfix) with ESMTP id 1559C37B423 for ; Tue, 1 May 2001 02:56:31 -0700 (PDT) (envelope-from neugebar@dcs.gla.ac.uk) Received: from therese.dcs.gla.ac.uk ([130.209.241.134] helo=therese.dcs.gla.ac.uk.dcs.gla.ac.uk) by iona.dcs.gla.ac.uk with esmtp (Exim 3.13 #1) id 14uWtS-0005wA-00 for freebsd-alpha@FreeBSD.ORG; Tue, 01 May 2001 10:56:30 +0100 Received: by therese.dcs.gla.ac.uk.dcs.gla.ac.uk (8.11.2/Dumb) id f419uRQ86712; Tue, 1 May 2001 10:56:28 +0100 (BST) To: freebsd-alpha@FreeBSD.ORG Subject: Re: determine cycle counter frequency in user space References: <200104302147.OAA12404@usr01.primenet.com> From: Rolf Neugebauer Date: 01 May 2001 10:56:27 +0100 In-Reply-To: Terry Lambert's message of "Mon, 30 Apr 2001 21:47:48 +0000 (GMT)" Message-ID: Lines: 35 User-Agent: Gnus/5.0805 (Gnus v5.8.5) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-alpha@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Terry Lambert writes: > > 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. Not on my 4.2-STABLE, late February vintage. I could parse hw.model, but that reports 533MHz, while dmesg reports 531MHz. In a followup, Mike mentioned fluctuations of clock frequency. Any idea, by how much this fluctuation can be? percentage of MHz, kHz? In general, I am not too fussed about these fluctuations, as I can take some fine grained samples using cycle counters together with more coarse grained once obtained from gettimeofday(). However, to get an estimate for cycles per second, I was looking for a programmatic way to access above mentioned variables instead of providing them as command line arguments. I'll just add an appropriate sysctl to get cycles_per_sec. If people are interested, I'll submit a patch. Thanks Rolf To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message