PDA

View Full Version : Method to find the Number of processors in a system



murajashekar2003
September 18th, 2007, 10:11 AM
Warm wishes All,

Is there any other way to find the number of processors of a system.

One way is through cat /proc/cpuinfo.

Do we have anyother alternative way?If so how..

thanks in advance!
Cheers..
Rajasekar

ghostdog74
September 18th, 2007, 10:42 AM
dmesg |grep processor

CptPicard
September 18th, 2007, 11:10 AM
http://www.uwsg.indiana.edu/hypermail/linux/kernel/0204.1/0132.html

Comes up as the very first Google search result for "linux kernel system calls number of processors" ;)

Seems like there are ways to do this in code, but even they parse cpuinfo. So I guess that's your best bet. Although the ...stat...whatever ones look interesting too.

AlexThomson_NZ
September 18th, 2007, 07:55 PM
I have implemented this in a program (check these forums for a benchmarking thread by me). I used /proc/cpuinfo and it is very robust- be careful about just doing a grep for 'processor' though, as it sometimes appears in (the model name

Lster
November 26th, 2007, 10:29 PM
Hi!

I was just searching through the forums for the same thing! Looking in LibC I found this functionality. I haven't tried it yet but I thought I would post here in case anyone is interested.

http://www.gnu.org/software/libc/manual/html_node/Processor-Resources.html#Processor-Resources

And yes! I do realize this thread is old... ish!