The Linux CPU number judgment command

  
can be obtained as long as
#include <unistd.h>long num = sysconf(_SC_NPROCESSORS_ONLN);

. . .

Judgement basis: 1. The cpu with the same core id is the hyperthread of the same core. 2. A cpu with the same physical id is the same cpu-encapsulated thread or cores.

English version: 1.Physical id and core id are not consecutive consecutive but they are unique. Any cpu with the same core id are hyperthreads in the same core.2.Any cpu with the same physical id are threads Or cores in the same physical socket.

Instance:

LunarPages CPU information:

processor : 0vendor_id : GenuineIntelcpu family : 15model : 4model name : Intel(R) Xeon (TM) CPU 3.00GHzstepping: 3cpu MHz: 3000.881cache size: 2048 KBphysical id: 0siblings: 2core id: 0cpu cores: 1fdiv_bug: nohlt_bug: nof00f_bug: nocoma_bug: nofpu: yesfpu_exception: yescpuid level: 5wp: yesflags: 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 pbe lm constant_tsc pni monitor ds_cpl cid xtprbogomips: 6006.73


processor: 1vendor_id: GenuineIntelcpu family : 15model : 4model name : Intel(R) Xeon(TM) CPU 3.00GHzstepping : 3cpu MHz : 3000.881cache size : 2048 KBphysical id : 0siblings : 2core id : 0cpu cores: 1fdiv_bug: nohlt_bug: nof00f_bug: nocoma_bug: nofpu: yesfpu_exception: yescpuid level: 5wp: yesflags: 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 pbe Lm constant_tsc pni monitor ds_cpl cid xtprbogomips : 5999.40


processor : 2vendor_id : GenuineIntelcpu family : 15model : 4model name : Intel(R) Xeon(TM) CPU 3.00GHzstepping : 3cpu MHz : 3000.881cache size: 2048 KBphysical id: 3siblings: 2core id: 3cpu cores: 1fdiv_bug: nohlt_bug: nof00f_bug: nocoma_bug: nofpu: yesfpu_exception: yescpuid level: 5wp: yesflags: 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 pbe lm constant_tsc pni monitor ds_cpl cid xtprbogomips: 5999.08


processor: 3vendor_id: GenuineIntelcpu family: 15model: 4model name: Intel (R) Xeon(TM) CPU 3.00GHzstepping : 3cpu MHz : 3000.881cache size : 2048 KBphysical id : 3siblings: 2core id: 3cpu cores: 1fdiv_bug: nohlt_bug: nof00f_bug: nocoma_bug: nofpu: yesfpu_exception: yescpuid level: 5wp: yesflags: 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 pbe lm constant_tsc pni monitor ds_cpl cid xtprbogomips : 5999.55

Shows 4 logical CPUs, through the physical id, the first two logical cpus are the same, the latter two are the same, so there are two physical CPUs . The core ids of the first two are the same, and the two core IDs are the same, indicating that both CPUs are single core. That is to say two single-core cpu, with Hyper-Threading technology enabled. Through the parameters of Intel's cpu, you can initially judge the use of two Xeon Pentium 4 CPUs, which is a bit poor. . . . How to get the details of the CPU:

linux command:

#cat /proc/cpuinfo

Use the command to judge 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 in each physical CPU: # cat /proc/cpuinfo |  Grep 'cpu cores' |  Wc -l

Is it hyperthreaded? If there are two logical CPUs with the same "core id", then hyperthreading is turned on.

The number of logical CPUs (possibly core, threads or both) in each physical CPU: # cat /proc/cpuinfo |  Grep 'siblings' other features:

Attel's new multi-core cpu will display specific model numbers at the end, for example:

model name : Intel(R) Xeon(R) CPU < Wbr> X3230 @ 2.66GHz

Note is Xeon 3230 Cpu, without showing the specific number of models, most of them are Pentium CPU

Many hosting companies are deceiving, with Pentium cpu, but it is multi-core CPU.

Data seen by the probe:

Type: Intel(R) Xeon(TM) CPU 2.80GHz Cache: 1024 KB Type: Intel(R) Xeon(TM) CPU 2.80GHz Cache : 1024 KB Type: Intel(R) Xeon(TM) CPU 2.80GHz Cache: 1024 KB Type: Intel(R) Xeon(TM) CPU 2.80GHz Cache: 1024 KB

No specific model, cache 1M It is generally the cpu of the Pentium series, or the cpu of the intel pseudo-core, which should be judged according to the above. The new multi-core cpu can see the specific model. In addition, the multi-core xeon CPU, the general frequency is not high, only a few high-end CPU models up to 2.8 and 3.0, the general host will not use such a good.

The latest version of some OS
has updated the /proc/cpuinfo file to support multiple platforms. If the /proc/cpuinfo file on your system correctly reflects the processor information, you do not need to perform the above steps. Instead, the information in this article can be used for explanation.

The /proc/cpuinfo file contains the data paragraphs for each processor on the system. There are six entries in the /proc/cpuinfo description for multi-core and hyper-threading (HT) technology 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 socket. 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 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 different core ids, this is a multi-core processor. The cpu cores entry can also indicate whether multicore support is supported.

For example, if your system contains two physical packages, each containing two processor cores that support Hyper-Threading (HT) technology, the /proc/cpuinfo file will contain this data.
zh-CN"],null,[0.97938782],zh-CN"]]]

Copyright © Windows knowledge All Rights Reserved