CPU寄存器的副本 [英] copy of CPU registers

查看:120
本文介绍了CPU寄存器的副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在研究线程之间共享资源时,我发现每个线程都有自己的堆栈和CPU寄存器的副本."
我知道每个线程都有自己的堆栈,但是它将如何拥有自己的CPU寄存器副本?

预先感谢.

Hi all,

While studying about sharing resources in between threads I found that "Each thread has its own stack and its own copy of the CPU registers."
I know that each thread has its own stack but how will it have its own copy of CPU registers?

Thanks in advance.

推荐答案

线程是独立的CPU进程:它们为CPU寄存器节省了空间(在线程控制块或堆栈中),因此可以完全恢复线程被挂起时的状态-这不仅适用于Windows线程或.NET线程类,它是多任务处理的一般规则.暂挂任务的第一步:保存当前状态,包括PC,标志和寄存器.重新启动任务时的最后一个任务:恢复所有保存的上下文.

这个想法是任务/线程不知道它曾经被挂起过-从头到尾看起来像是无缝运行.如果您没有保存CPU寄存器,那将不会发生!
Threads are independent CPU processes: they have space saved (either in the thread control block, or on the stack) for the CPU registers, so that the status of the thread can be restored exactly as it was when the thread was suspended - this isn''t just applicable to Windows Threads or to .NET Thread classes, it is a general rule of multitasking. First action on suspending a task: Save the current status, including PC, flags, and registers. Last task when restarting a task: Restore all saved context.

The idea is that the task / thread does not know that it was ever suspended - it looks like a seamless run from beginning to end. If you didn''t save the CPU registers, that would not happen!


这篇关于CPU寄存器的副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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