From owner-freebsd-questions Tue Dec 5 19: 2:27 2000 From owner-freebsd-questions@FreeBSD.ORG Tue Dec 5 19:02:24 2000 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from area51.v-wave.com (area51.v-wave.com [24.108.173.252]) by hub.freebsd.org (Postfix) with SMTP id 7F20E37B400 for ; Tue, 5 Dec 2000 19:02:23 -0800 (PST) Received: (qmail 26165 invoked by uid 1001); 6 Dec 2000 03:02:17 -0000 Date: Tue, 5 Dec 2000 20:02:17 -0700 From: Chris Wasser To: Matt Rudderham Cc: freebsd-questions@FreeBSD.ORG Subject: Re: CPU Speed? Message-ID: <20001205200217.A26052@skunkworks.area51-arpa.mil> References: <20001206022104.193653E09@bazooka.unixfreak.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from matt@researcher.com on Tue, Dec 05, 2000 at 10:24:01PM -0400 X-Operating-System: FreeBSD 4.2-STABLE Sender: flatline@area51.v-wave.com Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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: Architecture: i386 Number of CPUs: 1 CPU Model: Pentium II/Pentium II Xeon/Celeron CPU Speed: 400MHz Total Memory: 124MB User Memory: 104MB --- cut --- /* * FreeBSD CPU Information 0.1 * --------------------------- * Simple program to display the total RAM, and CPU information. * Compile: cc -o cpuinfo cpuinfo.c * --------------------------- * Omachonu Ogali */ #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.1\n"); printf("http://tribune.intranova.net\n\n"); len = sizeof(cpuarch); if (sysctlbyname("hw.machine_arch", &cpuarch, &len, NULL, NULL) == -1) { perror("sysctlbyname()"); return -1; } len = sizeof(cpumodel); if (sysctlbyname("hw.model", &cpumodel, &len, NULL, NULL) == -1) { perror("sysctlbyname()"); return -1; } len = sizeof(cpuspeed); if (sysctlbyname("machdep.tsc_freq", &cpuspeed, &len, NULL, NULL) == -1) { perror("sysctlbyname()"); return -1; } len = sizeof(numcpu); if (sysctlbyname("hw.ncpu", &numcpu, &len, NULL, NULL) == -1) { perror("sysctlbyname()"); return -1; } len = sizeof(totalmem); if (sysctlbyname("hw.physmem", &totalmem, &len, NULL, NULL) == -1) { perror("sysctlbyname()"); return -1; } len = sizeof(usermem); if (sysctlbyname("hw.usermem", &usermem, &len, NULL, NULL) == -1) { perror("sysctlbyname()"); return -1; } cpuspeed = cpuspeed / 1000000; totalmem = (totalmem - 1048576) / 1048576; usermem = (usermem - 1048576) / 1048576; printf("Architecture:\t%s\n", cpuarch); printf("Number of CPUs:\t%d\n", numcpu); printf("CPU Model:\t%s\n", cpumodel); printf("CPU Speed:\t%dMHz\n", cpuspeed); printf("Total Memory:\t%dMB\n", totalmem); printf("User Memory:\t%dMB\n", usermem); printf("\n"); return 0; } --- cut --- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message