Re: system call for finding the number of cpus??

Dr. David Alan Gilbert (gilbertd@nospam.treblig.org)
Mon, 8 Apr 2002 23:02:39 +0100


* Mark Hahn (hahn@physics.mcmaster.ca) wrote:
> > See http://people.nl.linux.org/~hch/cpuinfo/ for details.
>
> egads. "grep -ci bogo /proc/cpuinfo" then.

Hmm, cpuinfo is a very human readable file, I wouldn't use it to do
things like that.

I suggest /proc/stat whose format appears to be designed for machine
reading and which has a 'cpu0' and 'cpu1' line on this here dual
processor box; and from 2.4.x on it seems to have a cpu0 even on
uniprocessor; so I suggest:

grep "^cpu[0-9][0-9]* " /proc/stat

But I'd actually go and ask the CPU hotswap guys - they must have a way
of getting a handle on this (hey does that mean you might have cpu0,
cpu1, cpu3 .... ?)

Me thinks the format of these /proc files needs documenting - is there
anything already?

Dave

---------------- Have a happy GNU millennium! ----------------------
/ Dr. David Alan Gilbert | Running GNU/Linux on Alpha,68K| Happy \
\ gro.gilbert @ treblig.org | MIPS,x86,ARM, SPARC and HP-PA | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/