From owner-freebsd-questions Wed Dec 6 1:13:18 2000 From owner-freebsd-questions@FreeBSD.ORG Wed Dec 6 01:13:14 2000 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-26-235-186.mmcable.com [65.26.235.186]) by hub.freebsd.org (Postfix) with SMTP id 6C66237B400 for ; Wed, 6 Dec 2000 01:13:14 -0800 (PST) Received: (qmail 85893 invoked by uid 100); 6 Dec 2000 09:13:13 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14894.809.552364.994617@guru.mired.org> Date: Wed, 6 Dec 2000 03:13:13 -0600 (CST) To: Chris Wasser Cc: questions@freebsd.org Subject: Re: CPU Speed? In-Reply-To: <78629760@toto.iv> X-Mailer: VM 6.75 under 21.1 (patch 10) "Capitol Reef" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ X-Message: You should get a better mailer. Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Chris Wasser types: > On Tue 05 Dec 2000, Matt Rudderham wrote: > > Me as well, a 133MHz and a 200MHz system both come up with above response. I > > am interested in the answer now though:) > > - Matt > > Try this on for size (previously posted to the mailing list), produces > output as such: Doesn't work on my machine - no hw.tsc_freq. In fact, nothing there seems to be right. FWIW, here's a tweaked version of that program that gives you whatever information it can get, and warns you about what it can't. */ #include #include #include #include #include #include extern int errno; int main(void) { int len, numcpu, cpuspeed, totalmem, usermem; char cpuarch[64], cpumodel[64]; printf("FreeBSD CPU Information\n"); printf("Version 0.2\n"); printf("http://tribune.intranova.net\nhttp://www.mired.org/\n\n"); len = sizeof(cpuarch); if (sysctlbyname("hw.machine_arch", &cpuarch, &len, NULL, NULL) == -1) { perror("sysctlbyname(hw.machine_arch)"); cpuarch[0] = 0; } len = sizeof(cpumodel); if (sysctlbyname("hw.model", &cpumodel, &len, NULL, NULL) == -1) { perror("sysctlbyname(hw.model)"); cpumodel[0] = 0; } len = sizeof(cpuspeed); if (sysctlbyname("machdep.tsc_freq", &cpuspeed, &len, NULL, NULL) == -1) { perror("sysctlbyname(machdep.tsc_freq)"); cpuspeed = -1; } len = sizeof(numcpu); if (sysctlbyname("hw.ncpu", &numcpu, &len, NULL, NULL) == -1) { perror("sysctlbyname(hw.ncpu)"); numcpu = -1; } len = sizeof(totalmem); if (sysctlbyname("hw.physmem", &totalmem, &len, NULL, NULL) == -1) { perror("sysctlbyname(hw.physmem)"); totalmem = -1; } len = sizeof(usermem); if (sysctlbyname("hw.usermem", &usermem, &len, NULL, NULL) == -1) { perror("sysctlbyname(hw.usermem)"); usermem = -1; } if (cpuarch[0]) printf("Architecture:\t%s\n", cpuarch); if (numcpu > 0) printf("Number of CPUs:\t%d\n", numcpu); if (cpumodel[0]) printf("CPU Model:\t%s\n", cpumodel); if (cpuspeed > 0) printf("CPU Speed:\t%dMHz\n", cpuspeed / 1000000); if (totalmem > 0) printf("Total Memory:\t%dMB\n", (totalmem - 1048576) / 1048576); if (usermem > 0) printf("User Memory:\t%dMB\n", (usermem - 1048576) / 1048576); printf("\n"); return 0; } -- Mike Meyer http://www.mired.org/home/mwm/ Independent WWW/Unix/FreeBSD consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message