Re: Determine clock speed
From: Peter C. Tribble (ptribble_at_hgmp.mrc.ac.uk)
Date: 01/28/05
- Next message: Emmanuel Florac: "Re: Creation of solaris package larger than 2GB fails"
- Previous message: swamp boy: "Re: Determine clock speed"
- In reply to: Josh Lessard: "Determine clock speed"
- Next in thread: barts_at_smaalders.net: "Re: Determine clock speed"
- Reply: barts_at_smaalders.net: "Re: Determine clock speed"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 28 Jan 2005 21:22:42 +0000 (UTC)
In article <C9WdnRgsPMmIO2fcRVn-qw@rogers.com>,
Josh Lessard <NOjlessardSPAM@rogers.com> writes:
> How can I determine, in software, the clock speed in MHz of the SPARC
> machine I'm using? Is there a system call/C function I can use to find
> this information?
Fairly easy using kstats
For example, assuming you're using Solaris 8 or later, the command:
kstat cpu_info:::clock_MHz
will do the trick. A fragment of C to do the same thing (with no
error checking...)
#include <kstat.h>
#include <stdio.h>
main(void)
{
kstat_ctl_t *kc;
kstat_t *ksp;
kstat_named_t *kn;
kc = kstat_open();
/*
* replace the two 0s by the number of your cpu
* or walk the chain
*/
ksp = kstat_lookup(kc, "cpu_info", 0, "cpu_info0");
kstat_read(kc, ksp, 0);
kn = kstat_data_lookup(ksp, "clock_MHz");
printf("%ld\n", kn->value.i32);
exit(0);
}
-- -Peter Tribble MRC Rosalind Franklin Centre for Genomics Research http://www.rfcgr.mrc.ac.uk/~ptribble/ - http://ptribble.blogspot.com/
- Next message: Emmanuel Florac: "Re: Creation of solaris package larger than 2GB fails"
- Previous message: swamp boy: "Re: Determine clock speed"
- In reply to: Josh Lessard: "Determine clock speed"
- Next in thread: barts_at_smaalders.net: "Re: Determine clock speed"
- Reply: barts_at_smaalders.net: "Re: Determine clock speed"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]