The number of Linux CPUs is judged by/proc/cpuinfo.
Same Physical ID: determines a physical processor
If "siblings" and "CPU cores" are consistent, hyper-threading is not supported, or hyper-threading is not open.
If "siblings" is twice Times "CPU cores", then hyper-Threading is supported and Hyper-threading is turned on.
In fact, just
#include <unistd.h>
Long num = sysconf (_SC_NPROCESSORS_ONLN);
You can get the current number of CPUs ...
Basis of judgment:
1. CPUs with the same core ID are Hyper-threading of the same core.
2. CPUs with the same physical ID are the same CPU-encapsulated thread or cores.
English version:
1.Physical ID and Core ID is not necessarily consecutive but they is unique. Any CPUs with the same core ID is hyperthreads in the same core.
2.Any CPU with the same physical ID is threads or cores in the same physical socket.
Instance:
Lunarpages CPU Information:
processor:0
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical id:0
Siblings:2
Core id:0
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE SSE2 SS HT TM PB E lm constant_tsc PNI monitor ds_cpl CID XTPR
bogomips:6006.73
Processor:1
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical id:0
Siblings:2
Core id:0
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE SSE2 SS HT TM PB E lm constant_tsc PNI monitor ds_cpl CID XTPR
bogomips:5999.40
Processor:2
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical Id:3
Siblings:2
Core Id:3
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE SSE2 SS HT TM PB E lm constant_tsc PNI monitor ds_cpl CID XTPR
bogomips:5999.08
Processor:3
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical Id:3
Siblings:2
Core Id:3
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE SSE2 SS HT TM PB E lm constant_tsc PNI monitor ds_cpl CID XTPR
bogomips:5999.55
Displays 4 logical CPUs, with the same physical ID, two logical CPUs in front, and two later, so there are two physical CPUs. The first two cores have the same core ID, followed by the same two core IDs, indicating that the two CPUs are single-core. That is, two single-core CPUs with Hyper-Threading technology enabled.
The parameters of Intel's CPU can be initially judged using two Xeon Pentium 4CPU, a little worse ....
How to obtain detailed information about the CPU:
Linux command: Cat/proc/cpuinfo
Use the command to determine several physical CPUs, several cores, etc.:
Number of logical CPUs:
# Cat/proc/cpuinfo | grep ' Processor ' | Wc-l
Number of physical CPUs:
# Cat/proc/cpuinfo | grep ' Physical ID ' | Sort | Uniq | Wc-l
Number of cores per physical CPU:
# Cat/proc/cpuinfo | grep ' CPU cores ' | Wc-l
Is it hyper-threading?
If there are two logical CPUs with the same "core ID", then Hyper-threading is turned on.
The number of logical CPUs (possibly cores, threads, or both) in each physical CPU:
# Cat/proc/cpuinfo | grep ' siblings '
Other Features:
At present, Intel's new multi-core CPU will display the specific model numbers later, for example:
Model Name:intel (R) Xeon (r) CPU X3230 @ 2.66GHz
Description is the Xeon 3230 CPU, not the exact number of the model, most of it is the Pentium CPU
Many hosts cheat, with the Pentium CPU, but that is the multi-core CPU.
The data that the probe sees:
Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024x768
Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024x768
Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024x768
Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024x768
No specific model, cache 1M, is generally the Pentium series of CPUs, or Intel fake dual-core CPU, specifically according to the above to judge. The new multi-core CPU can see the specific model.
Another multi-core Xeon CPU, the general frequency is not high, reached 2.8 and 3.0 only a few high-end CPU models, the general host will not use such a good.
The latest version of some operating systems has updated the/proc/cpuinfo file to support multi-channel platforms. If the/proc/cpuinfo file in your system correctly reflects the processor information, you do not need to perform the above steps. Conversely, the information in this article can be used for interpretation.
The/proc/cpuinfo file contains a paragraph of data for each processor on the system. There are 6 entries in the/proc/cpuinfo description for multi-core and Hyper-Threading (HT) Technical checks: processor, vendor ID, physical ID, siblings, core ID, and CPU cores.
The processor entry includes a unique identifier for this logical processor.
The physical ID entry includes a unique identifier for each physical package.
The core ID entry holds a unique identifier for each kernel.
The siblings entry lists the number of logical processors in the same physical package.
The CPU cores entry contains the number of cores in the same physical package.
If the processor is an Intel processor, the string in the vendor ID entry is Genuineintel.
1. All logical processors with the same physical ID share the same physical outlet. Each physical ID represents a unique physical package.
2.Siblings represents the number of logical processors located on this physical package. They may or may not support Hyper-Threading (HT) technology.
3. Each core ID represents a unique processor core. All logical processors with the same core ID are located on the same processor core.
4. If more than one logical processor has the same core ID and physical ID, the system supports Hyper-threading (HT) technology.
5. If two or more logical processors have the same physical ID, but the core ID is different, this is a multi-core processor. CPU cores entries can also indicate whether multiple cores are supported.
For example, if the system contains two physical packages, and each package contains two processor cores that support Hyper-Threading (HT) technology, the/proc/cpuinfo file will contain this data. (Note: The data is not in the table.) )
The number of Linux CPUs is judged by/proc/cpuinfo.