可以同时运行2个线程吗?还是只有1个? (考虑到超线程的可能性) [英] Can 2 threads run concurrently? Or just 1? (given the possibility of hyperthreading)

查看:408
本文介绍了可以同时运行2个线程吗?还是只有1个? (考虑到超线程的可能性)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是cat /etc/cpuinfo的输出,并且没有说明内核是否为超线程.如何确定两个线程是否可以潜在地同时运行?

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:

推荐答案

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

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

如果仅处理器:0,则您有一个物理CPU.这意味着一次只能真正运行一个线程.引用关于超线程的维基百科页面:

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:

它们在OS中显示为两个处理器,因此OS可以一次调度两个进程.另外,两个或多个进程可以使用相同的资源.如果一个进程失败,则可以很容易地重新分配资源.

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.

因此,我非常确定,即使使用超线程,它们也将在您的EC2虚拟机中显示为多个CPU条目:处理器:1,处理器:2,...,如果存在的话.

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.

这篇关于可以同时运行2个线程吗?还是只有1个? (考虑到超线程的可能性)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆