From owner-freebsd-questions@FreeBSD.ORG Fri Jan 9 15:42:17 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4D9C816A4CE for ; Fri, 9 Jan 2004 15:42:17 -0800 (PST) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 37A9843D48 for ; Fri, 9 Jan 2004 15:42:16 -0800 (PST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id i09NgFlW056064; Fri, 9 Jan 2004 17:42:15 -0600 (CST) (envelope-from dan) Date: Fri, 9 Jan 2004 17:42:15 -0600 From: Dan Nelson To: Palle Girgensohn Message-ID: <20040109234215.GB3393@dan.emsphone.com> References: <300110000.1073689940@palle.girgensohn.se> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <300110000.1073689940@palle.girgensohn.se> X-OS: FreeBSD 5.2-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.5.1i cc: freebsd-questions@freebsd.org Subject: Re: how find out CPU clockrate? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2004 23:42:17 -0000 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