线程之间如何共享寄存器?
我知道堆栈是每个线程的,但是寄存器是有限的,就像在 IA32 上一样,只有 8 个寄存器。
那么线程之间如何共享寄存器呢?
I know that stacks are per thread, but registers are limited,like on IA32,only 8 registers.
So how are registers shared among threads?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当 CPU 当前运行特定线程时,将使用寄存器。当操作系统决定从一个线程切换到另一个线程时,操作系统会将所有寄存器的当前值保存到特定于第一个线程的私有内存区域中。在第二个线程开始运行之前,操作系统从其保存的区域加载所有寄存器的值。这称为上下文切换。
Registers are used by the CPU when it's currently running a particular thread. When the OS decides to switch from one thread to another, the OS saves the current values of all the register into a private memory area specific to the first thread. Before the second thread starts running, the OS loads the values of all the registers from its saved area. This is called a context switch.