Date: Tue, 5 Dec 2000 20:02:17 -0700 From: Chris Wasser <cwasser@v-wave.com> To: Matt Rudderham <matt@researcher.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: CPU Speed? Message-ID: <20001205200217.A26052@skunkworks.area51-arpa.mil> In-Reply-To: <NDBBLEKOOLGIBFPGLFEKEEKOCJAA.matt@researcher.com>; from matt@researcher.com on Tue, Dec 05, 2000 at 10:24:01PM -0400 References: <20001206022104.193653E09@bazooka.unixfreak.org> <NDBBLEKOOLGIBFPGLFEKEEKOCJAA.matt@researcher.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <oogali@intranova.net>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/sysctl.h>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001205200217.A26052>
