For those who use Windows, there is an environment variable that comes pre-loaded, NUMBER_OF_PROCESSORS.
This variable contains the number of processors that a program might want to know to allow for parallel operations.
But in this day and age, the number of actual processors and the number reported may differ by a factor of two. The technology that allows this is called hyperthreading. Hyperthreading has been around for more than ten years.
A CPU chip may have two physical cores, but with hyperthreading, the operating system is presented with four processors.
Under Windows, NUMBER_OF_PROCESSORS is the hyperthreading number.
Under Linux, we can run a set of commands and get both.
NUMBEROFPROCESSORS=`cat /proc/cpuinfo | grep 'core id' | wc -l`
echo "Number of Processors="$NUMBEROFPROCESSORS
# Get the number of hyperthreaded processors
NUMBEROFHTTPROCESSORS=`cat /proc/cpuinfo | grep processor | wc -l`
echo "Number of Hyperthreaded Processors="$(($NUMBEROFHTTPROCESSORS-$NUMBEROFPROCESSORS))
My results are as follows. I'm running on an Intel(c) Core(tm)2 T9400. It does not support hyperthreading.
Number of Hyperthreaded Processors=0
Nice discussion on the why's and wherefore's of processors, physical ids, and cores here.
Busy - SluggishNow that you have enabled make to use all the available processors, be prepared for your system to get sluggish.
On a build machine you want to build fast. On a development machine you want to do something else, but you just told make to use all the available CPUs. Ctrl-C might not even be effective, for a while.
Your mileage may vary. Forewarned is forearmed.
Number of Processors + 1
The reason for this would be a subject of a separate blog. Exercise for the reader. :)