加载中…
个人资料
前沿博客
前沿博客
  • 博客等级:
  • 博客积分:0
  • 博客访问:52,433
  • 关注人气:2
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
相关博文
推荐博文
谁看过这篇博文
加载中…
正文 字体大小:

多线程

(2009-03-27 14:43:00)
标签:

杂谈

多线程

Sunday, August 10th, 2008 星期日, 2008年8月10日

Multithreading computers have hardware support to efficiently execute multiple threads.多线程的计算机有硬件支持有效地执行多个线程。 Theseare distinguished from multiprocessing systems (such as multi-coresystems) in that the threads must all operate in the same addressspace, as there is only one shared set of CPU caches and onetranslation lookaside buffer (TLB).这是有别于多处理系统(如多核心系统)中的线程都必须在相同的地址空间,只有一个共同的一套CPU的高速缓存和一个转换后备缓冲器(你们) 。 Asa result, multithreading can only take advantage of parallelism withina program, whereas multiprocessing systems can run multiple programs inparallel.因此,多线程只能利用并行程序内,而多处理器系统可以运行多个程序并行。 Wheremultiprocessing systems include multiple complete processing units,multithreading aims to increase utilization of a single core byleveraging thread-level as well as instruction-level parallelism.凡多处理系统中包含多个完整的处理单元,多线程的目的是更多地利用一个单一的核心,通过利用线程级别以及指令级并行。 Asthe two techniques are complementary, they are sometimes combined insystems with multiple multithreading CPUs and in CPUs with multiplemultithreading cores.由于两种技术是互补的,他们有时在系统相结合的多线程处理器和多处理器的多线程内核。
Overview概览
TheMultithreading paradigm has become more popular as efforts to furtherexploit instruction level parallelism have stalled since the late-1990s.多线程模式已变得更加受欢迎的努力,进一步利用指令级并行已经停止后期以来, 20世纪90年代。 Thisallowed the concept of Throughput Computing to reemerge to prominencefrom the more specialized field of transaction processing:这使得概念吞吐量计算,以重现突出从更专业的交易处理:

*Even though it is very difficult to further speed up a single thread orsingle program, most computer systems are actually multi-tasking amongmultiple threads or programs. *即使是一件非常困难的进一步加快单一线程或单一项目,大多数的计算机系统实际上是多任务多线程之间或程序。
* Techniques that would allow speedup of the overall system throughput of all tasks would be a meaningful performance gain. *技术,将使加速整个系统的吞吐量,所有的任务将是一个有意义的性能增益。

The two major techniques for throughput computing are multiprocessing and multithreading.这两大技术的吞吐量计算的多重和多线程。

Some criticisms of multithreading include:一些批评的多线程包括:

*Multiple threads can interfere with each other when sharing hardwareresources such as caches or translation lookaside buffers (TLBs). *多线程可以互相干扰时共享硬件资源,如缓存或转换后备缓冲器( TLBs ) 。
* Execution times of a single-thread are not improved but can be degraded. *执行时间的单线程不改善,但可退化。
*Hardware support for Multithreading is more visible to software, thusrequiring more changes to both application programs and operatingsystems than Multiprocessing. *硬件支持多线程是可见的软件,因此需要更多的变化都应用程序和操作系统比多处理。

Hardwaretechniques used to support multithreading often parallel the softwaretechniques used for computer multitasking of computer programs.硬件技术,用于支持多线程往往平行的软件技术用于电脑的多任务的计算机程序。
Block multi-threading块多线程
Concept概念
Thesimplest type of multi-threading is where one thread runs until it isblocked by an event that normally would create a long latency stall.最简单的一种多线程是一个线程运行,直到它被拦截的事件,通常会造成长期潜伏摊档。 Sucha stall might be a cache-miss that has to access off-chip memory, whichmight take hundreds of CPU cycles for the data to return.这样一个摊位可能是缓存错过了访问片外存储器,这可能需要数百个CPU周期的数据返回。 Insteadof waiting for the stall to resolve, a threaded processor would switchexecution to another thread that was ready to run.而不是等待解决的摊位,一个线程处理器将切换到另一台执行线程准备运行。 Onlywhen the data for the previous thread had arrived, would the previousthread be placed back on the list of ready-to-run threads.只有当数据的前线程已抵达,将以前的线程放在回到名单上随时运行线程。

For example:例如:

1. 1 。 Cycle i  : instruction j from thread A is issued循环一:教学j从线程A是发行
2. 2 。 Cycle i+1: instruction j+1 from thread A is issued周期字母i +1 : j +1指示从线程A是发行
3. 3 。 Cycle i+2: instruction j+2 from thread A is issued, load instruction which misses in all caches周期字母i 2 :指示j 2线程A是从发行,负载指示而忽略所有缓存
4. 4 。 Cycle i+3: thread scheduler invoked, switches to thread B周期字母i 3 :线程调度程序调用,切换到线程乙
5. 5 。 Cycle i+4: instruction k from thread B is issued周期字母i 4 :指示k B是从线程发出
6. 6 。 Cycle i+5: instruction k+1 from thread B is issued周期字母i五:指示k +1从线程B是发行

Conceptually,it is similar to cooperative multi-tasking used in real-time operatingsystems in which tasks voluntarily give up execution time when theyneed to wait upon some type of event.从概念上来说,它类似于合作多任务中使用的实时操作系统,其中自愿放弃任务执行的时候,他们需要等待的某些类型的事件。

Terminology术语

This type of multithreading is known as Block or Cooperative or Coarse-grained multithreading.这种类型的多线程被称为块或合作或粗粒度多线程。

Hardware cost硬件成本

Thegoal of multithreading hardware support is to allow quick switchingbetween a blocked thread and another thread ready to run.的目标,多线程硬件支持是让之间的快速转换阻塞线程和另一个线程准备运行。 Toachieve this goal, the hardware cost is to replicate the programvisible registers as well as some processor control registers (such asthe program counter).为了实现这一目标,在硬件成本是复制程序可见寄存器以及一些处理器控制寄存器(如程序计数器) 。 Switching from one thread to another thread means the hardware switches from using one register set to another.开关由一个线程向另一个线程是指使用硬件开关设置为一个注册另一个。

Such additional hardware has these benefits:这种额外的硬件了以下好处:

* The thread switch can be done in one CPU cycle. *线程开关可以在一个CPU周期。
* It appears to each thread that they are executing alone and not sharing any hardware resources with any other threads. *这似乎每个线程,他们正在执行,而不是单独的硬件资源共享任何与任何其他线程。 Thisminimizes the amount of software changes needed within the applicationas well as the operating system to support multithreading.这样做可以减小数额的变化需要在软件的应用以及操作系统支持多线程。

In order to switch efficiently between active threads, each active thread needs to have its own register set.为了有效地之间切换积极线程,每个活跃线程都需要拥有自己注册成立。 For example, to quickly switch between two threads, the register hardware needs to be instantiated twice.例如,如果要快速切换两个线程,登记册硬件需要实例两次。

Examples实例

*Many families of microcontrollers and embedded processors have multipleregister banks to allow quick context switching for interrupts. *许多家庭的微控制器和嵌入式处理器拥有多个注册银行允许的范围内快速切换的中断。 Such schemes can be considered a type of block multithreading among the user program thread and the interrupt threads.这些计划可以被看作是一种类型的块多线程之间的用户程序线程和中断线程。
* Intel Super-threading *英特尔超级线程
* Intel Itanium 2 *英特尔安腾2
Interleaved multi-threading交错的多线程

See article: barrel processor

0

阅读 评论 收藏 转载 喜欢 打印举报/Report
后一篇:编程语言
  • 评论加载中,请稍候...
发评论

    发评论

    以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

    后一篇 >编程语言
      

    新浪BLOG意见反馈留言板 电话:4000520066 提示音后按1键(按当地市话标准计费) 欢迎批评指正

    新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 会员注册 | 产品答疑

    新浪公司 版权所有