From owner-freebsd-questions@FreeBSD.ORG Sun Sep 9 20:46:05 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC95D16A49C for ; Sun, 9 Sep 2007 20:46:05 +0000 (UTC) (envelope-from carpetsmoker@rwxrwxrwx.net) Received: from mail.rwxrwxrwx.net (rwxrwxrwx.net [82.93.23.199]) by mx1.freebsd.org (Postfix) with ESMTP id 44CF113C48E for ; Sun, 9 Sep 2007 20:46:04 +0000 (UTC) (envelope-from carpetsmoker@rwxrwxrwx.net) Received: by mail.rwxrwxrwx.net (Postfix, from userid 1001) id DE66C6D479; Sun, 9 Sep 2007 22:50:25 +0200 (CEST) Date: Sun, 9 Sep 2007 22:50:25 +0200 From: Martin Tournoij To: freebsd-questions@freebsd.org Message-ID: <20070909205025.GA40102@glitch.rwxrwxrwx.net> Mail-Followup-To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: mutt-ng/devel-r804 (FreeBSD) Subject: Getting the CPU frequency in C X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Sep 2007 20:46:05 -0000 I'm trying to get the CPU frequency in C: #include #include #include #include #include #include int main() { int mib[2]; size_t size; struct clockinfo clockrate; mib[0] = CTL_KERN; mib[1] = KERN_CLOCKRATE; size = sizeof clockrate; sysctl(mib, 2, &clockrate, &size, NULL, 0); fprintf(stdout, "hz: %i\n", clockrate.hz); fprintf(stdout, "tick: %i\n", clockrate.tick); fprintf(stdout, "spare: %i\n", clockrate.spare); fprintf(stdout, "stathz: %i\n", clockrate.stathz); fprintf(stdout, "profhz: %i\n", clockrate.profhz); return 0; } I tried to run this on two machines (one machine with hw.clockrate: 1378 and the other 797) and it outputs the same on both: hz: 1000 tick: 1000 spare: 0 stathz: 133 profhz: 666 The profhz value suggest the devil is at work :D although it's probably a some stupid mistake on my part :/ Can anyone help? Thanks, Martin Tournoij