什么是CPU寄存器,以及如何使用它们,尤其是多线程WRT? [英] What are CPU registers and how are they used, particularly WRT multithreading?

查看:97
本文介绍了什么是CPU寄存器,以及如何使用它们,尤其是多线程WRT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面这个问题,我的答案是,主要以应对另一个问题是混乱的区域。

This question and my answer below are mainly in response to an area of confusion in another question.

在回答结束时,有一些问题WRT的动荡与线程同步,我不是完全有信心 - 我欢迎意见和备选答案。问题的关键主要涉及到CPU寄存器以及它们是如何使用的不过,

At the end of the answer, there are some issues WRT "volatile" and thread synchronisation that I'm not entirely confident about - I welcome comments and alternative answers. The point of the question primarily relates to CPU registers and how they are used, however.

推荐答案

CPU寄存器是在CPU中的硅的数据存储的一小块区域。对于大多数的架构,他们的主要地方所有操作发生(数据会从内存中加载,运行,并推后了)。

CPU registers are small areas of data storage on the silicon of the CPU. For most architectures, they're the primary place all operations happen (data gets loaded in from memory, operated on, and pushed back out).

无论线程运行时使用的寄存器和拥有指令指针(它说该指令出现下一个)。当另一个线程操作系统互换,所有的CPU状态,包括寄存器和指令指针,得到的地方保存关闭,有效地冷冻干燥,当下次回来生命线程的状态。

Whatever thread is running uses the registers and owns the instruction pointer (which says which instruction comes next). When the OS swaps in another thread, all of the CPU state, including the registers and the instruction pointer, get saved off somewhere, effectively freeze-drying the state of the thread for when it next comes back to life.

在很多这一切更多文档,当然,所有的地方。 维基百科上的寄存器。 维基百科上下文切换。的对于初学者。编辑:或阅读Steve314的回答。 :)

Lots more documentation on all of this, of course, all over the place. Wikipedia on registers. Wikipedia on context switching. for starters. or read Steve314's answer. :)

这篇关于什么是CPU寄存器,以及如何使用它们,尤其是多线程WRT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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