线程之间如何共享寄存器?

发布于 2024-09-27 08:50:34 字数 76 浏览 0 评论 0原文

我知道堆栈是每个线程的,但是寄存器是有限的,就像在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以酷 2024-10-04 08:50:34

当 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文