Results 1 to 4 of 4
Hi,
So far I have tried all the available utilities to find the exact number of physical cpus on Linux but never succeeded.
I have used /proc/cpuinfo file but the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-18-2007 #1Just Joined!
- Join Date
- Dec 2007
- Posts
- 1
How to get number of physical processors/cores on Linux
Hi,
So far I have tried all the available utilities to find the exact number of physical cpus on Linux but never succeeded.
I have used /proc/cpuinfo file but the combination seems to work for one hosts but not for other and situation gets even worse while dealing different processors from same/different vendors like Intel , AMD etc.
Is there any c-code or utility availble which can provide this information correctly ?
Thanks
--Servesh
- 12-19-2007 #2
- 12-19-2007 #3forum.guy
- Join Date
- May 2004
- Location
- arch linux
- Posts
- 18,733
This works pretty well for me:
Code:grep cores /proc/cpuinfo
oz
- 08-21-2008 #4Just Joined!
- Join Date
- Jun 2008
- Location
- North East U.S.
- Posts
- 30
In a C program, I use the following as a more portable mechanism:
numCPUs = sysconf(_SC_NPROCESSORS_ONLN);
my biggest problem with this is that when Hyper Threading is enabled, that reports twice as many CPUs as I would like to see being reported.
-Brion


Reply With Quote
