Can 2 threads run concurrently? Or just 1? (given the possibility of hyperthreading)

狂风中的少年 提交于 2019-12-12 02:59:47

问题


The following is the output of cat /etc/cpuinfo and does not state whether the core is hyperthreaded or not. How do I find out whether or not two threads can potentially run concurrently?

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:


How do I find out whether or not two threads can potentially run concurrently?

If there is just processor: 0 then you have one physical CPU. This means that only one thread can be truly running at one time. Quoting from the wikipedia page on Hyperthreading:

They appear to the OS as two processors, thus the OS can schedule two processes at once. In addition two or more processes can use the same resources. If one process fails then the resources can be readily re-allocated.

So I'm pretty sure that even with hyperthreading, they would show up as multiple CPU entries as well in your EC2 virtual machine: processor: 1, processor: 2, ... if they existed.



来源:https://stackoverflow.com/questions/10183675/can-2-threads-run-concurrently-or-just-1-given-the-possibility-of-hyperthread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!