我怎样才能在 2 个内核上占用 400% 的 CPU

Mac*_*tka 13 linux cpu hyperthreading

我明白?(%CPU) ? logicalcores*(1+?)(其中 ? 是度量和舍入误差)。但是,如何在 2 核系统上拥有 2 个不同的进程,每个进程占用 200% 的 CPU(以 htop 衡量)?

编辑上述等式中的核心是指逻辑核心,即考虑所有超线程、CPU 数量等。

编辑 2尽管 htop 显示了我附加的处理器数量 cpuinfo

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 23
model name  : Intel(R) Core(TM)2 Duo CPU     T9600  @ 2.80GHz
stepping    : 10
cpu MHz     : 800.000
cache size  : 6144 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 2
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm ida dts tpr_shadow vnmi flexpriority
bogomips    : 5585.20
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 23
model name  : Intel(R) Core(TM)2 Duo CPU     T9600  @ 2.80GHz
stepping    : 10
cpu MHz     : 800.000
cache size  : 6144 KB
physical id : 0
siblings    : 2
core id     : 1
cpu cores   : 2
apicid      : 1
initial apicid  : 1
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm ida dts tpr_shadow vnmi flexpriority
bogomips    : 5586.38
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:
Run Code Online (Sandbox Code Playgroud)

ewi*_*sch 5

两个双核处理器包含 4 个 CPU。多线程处理器也存在。每个线程在操作系统中都表现为一个 CPU,尽管它们不像内核那样是真正的 CPU。大多数情况下,多线程 CPU 每个内核有两个线程,因此您可以拥有一个单双线程双核处理器,在您的操作系统中显示为 4 个 CPU。

应该注意的是,Sun Microsystems 有一个 T2 芯片,它有 8 个内核和每个内核 8 个线程,用于单个处理器上的 64 个虚拟 CPU。

  • 签入`/proc/cpuinfo` - 现在你在那里看到了多少 CPU.. (2认同)

bah*_*mat 5

单个物理超线程处理器将显示为两个逻辑处理器。因此,每个内核都带有超线程的双核处理器将显示为四个逻辑处理器,例如 top、cpuinfo、prstat、活动监视器等。


Gil*_*il' 0

您有 2 个处理器还是 4 个处理器?如果通过超线程有两个内核,每个内核有两个 CPU ,则总共有四个处理器(就操作系统而言)。