Date: Wed, 6 Dec 2000 03:13:13 -0600 (CST) From: Mike Meyer <mwm@mired.org> To: Chris Wasser <cwasser@v-wave.com> Cc: questions@freebsd.org Subject: Re: CPU Speed? Message-ID: <14894.809.552364.994617@guru.mired.org> In-Reply-To: <78629760@toto.iv>
next in thread | previous in thread | raw e-mail | index | archive | help
Chris Wasser <cwasser@v-wave.com> 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.
<mike
/*
* FreeBSD CPU Information 0.2
* ---------------------------
* 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.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 <mwm@mired.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14894.809.552364.994617>
