以下是cat /etc/cpuinfo
的输出,并没有说明内核是否是超线程的。如何确定两个线程是否可以同时运行?
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 26
model name : Intel(R) Xeon(R) CPU E5507 @ 2.27GHz
stepping : 5
microcode : 0x11
cpu MHz : 2266.750
cache size : 4096 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 6
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
flags : fpu de tsc msr pae cx8 sep cmov pat clflush mmx fxsr sse sse2 ss ht syscall nx lm constant_tsc up rep_good nopl nonstop_tsc pni ssse3 cx16 sse4_1 sse4_2 popcnt hypervisor lahf_lm
bogomips : 4533.50
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:
如何确定两个线程是否可以同时运行?
如果只有处理器:0,则您有一个物理 CPU。 这意味着一次只能有一个线程真正运行。 引用维基百科关于超线程的页面:
它们在操作系统中显示为两个处理器,因此操作系统可以同时调度两个进程。此外,两个或多个进程可以使用相同的资源。如果一个进程失败,则可以很容易地重新分配资源。
所以我很确定,即使使用超线程,它们也会在您的 EC2 虚拟机中显示为多个 CPU 条目:处理器:1,处理器:2,...如果它们存在的话。