Is there a system call that accurately returns CPU frequency?
Or is a do-it-yourself method the only option?
thanks
mh
--
Use PGP/GnuPG || DSS PGP Key: 0x4C7F2BEE
Beer: So much more than just a breakfast drink.
thanks
mh
--
Use PGP/GnuPG || DSS PGP Key: 0x4C7F2BEE
Beer: So much more than just a breakfast drink.
Interesting that you should ask that, because right nowQuote:>Is there a system call that accurately returns CPU frequency?
>Or is a do-it-yourself method the only option?
I think http://www.veryComputer.com/
will work as a direct link to the article.
- Logan
--
"Everybody
Loves to see
Justice done
On somebody else" ( Bruce*burn, "Justice", 1981 )
>thanks
>mh
You probably already know that there is a command to do so: 'psrinfo
-v'. psrinfo uses the kstat framework to figure this information out.
But psrinfo is pretty opaque. In Solaris 8 and later you can explore
kstats using the kstat(1M) command (which is actually a perl script you
can examine):
$ kstat -p 'cpu_info:::clock_MHz'
cpu_info:8:cpu_info8:clock_MHz 750
cpu_info:9:cpu_info9:clock_MHz 750
cpu_info:10:cpu_info10:clock_MHz 750
cpu_info:11:cpu_info11:clock_MHz 750
cpu_info:16:cpu_info16:clock_MHz 750
cpu_info:17:cpu_info17:clock_MHz 750
cpu_info:18:cpu_info18:clock_MHz 750
cpu_info:19:cpu_info19:clock_MHz 750
This helps you to find out the names of the kstats you are seeking; the
next step is to take a look at the kstat man pages. See especially
kstat_lookup(), kstat_open(), kstat_read() and friends. Something like
this works for me:
$ cat > speeds.c
#include <unistd.h>
#include <kstat.h>
int
main(void)
{
kstat_ctl_t *kc;
kstat_t *kstatp;
kstat_named_t *namedp;
if ((kc = kstat_open()) == NULL) {
exit(1);
}
/*
* Walk the kstat chain; find those whose module name is cpu_info.
* Read those kstats in, and look up clock_MHz in each one to find
* the CPU speed of each CPU on the system.
*/
for (kstatp = kc->kc_chain; kstatp != NULL; kstatp = kstatp->ks_next) {
if (strcmp(kstatp->ks_module, "cpu_info") == 0) {
int cpu = kstatp->ks_instance;
if (kstat_read(kc, kstatp, NULL) == -1)
exit(1);
namedp = (kstat_named_t *)kstat_data_lookup(kstatp,
"clock_MHz");
printf("cpu %d: %d MHz\n", cpu, namedp->value.l);
}
}
^DQuote:}
$ cc -o speeds speeds.c -lkstat
$ ./speeds
cpu 8: 750 MHz
cpu 9: 750 MHz
cpu 10: 750 MHz
cpu 11: 750 MHz
cpu 16: 750 MHz
cpu 17: 750 MHz
cpu 18: 750 MHz
cpu 19: 750 MHz
-dp
--
Expressed in this posting are my opinions. They are in no way related to
opinions held by my employer, Sun Microsystems. Statements on Sun products
included here are not gospel and may be fiction rather than truth.
1. Programs for CPU frequency and temp
Hi,
there are under kde programs that help me to visualize the frequency of CPU
and more important the temperature of CPU and also if possible of the whole
systems? I have installed a red hat 9 with kernel 2.4.20-8.
Regards,
--
Marco Mangiante
5. How to find out the CPU frequency
6. nullify ask to -passthru2 problem
8. Making directories crash server?
9. Haw to verify CPU frequency memory size
10. New: Changing the CPU frequency using CPUFREQ hangs the kernel
11. athlon 64: cpu frequency ?
12. CPU frequency