Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jan 2004 17:42:15 -0600
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Palle Girgensohn <girgen@pingpong.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: how find out CPU clockrate?
Message-ID:  <20040109234215.GB3393@dan.emsphone.com>
In-Reply-To: <300110000.1073689940@palle.girgensohn.se>
References:  <300110000.1073689940@palle.girgensohn.se>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Jan 10), Palle Girgensohn said:
> How can I programatically find out the CPU frequency?
> 
> I'm trying to port a program from Linux, and it uses /proc/cpuinfo.
> 
> $ cat /compat/linux/proc/cpuinfo
> cpu MHz         : 349.20
> 
> Pretty neat, but it does not exist in FreeBSD, and sysctl does not
> give out this information. Grepping the dmesg.boot seems somewhat odd
> for a C program:
> 
> $ dmesg | grep -i hz
> Timecounter "i8254"  frequency 1193182 Hz
> CPU: Pentium II/Pentium II Xeon/Celeron (349.20-MHz 686-class CPU)
> 
> Better ideas?

I think someone suggested that more CPU information be exported via
sysctl nodes at some point, but no-one has found it important enough to
code.  Note that on laptops and many ACPI motherboards, you can tweak
the CPU speed on the fly, so you can't just store the bootup value. 
Other architectures may also allow multiple CPUs at different speeds.

As for your issue, I'd say just comment the code out.  Do you really
need to know the CPU speed?  Another option is to shell out and run
cpuid or x86info, but those are x86-only, of course.

-- 
	Dan Nelson
	dnelson@allantgroup.com



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