2个线程可以同时运行吗?还是只有1? (考虑到超线程的可能性)

时间:2012-04-17 00:50:45

标签: linux multithreading cpu multicore

以下是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:

1 个答案:

答案 0 :(得分:1)

  

如何确定两个线程是否可以同时运行?

如果只有处理器:0那么你有一个物理CPU。这意味着一次只能运行一个线程。引自wikipedia page on Hyperthreading

  

它们在操作系统中显示为两个处理器,因此操作系统可以同时安排两个进程。此外,两个或多个进程可以使用相同的资源。如果一个进程失败,那么可以很容易地重新分配资源。

所以我很确定即使使用超线程,它们也会在您的EC2虚拟机中显示为多个CPU条目:处理器:1,处理器:2,......如果它们存在。

相关问题