汇编寄存器初学者 [英] assembly registers beginner

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

问题描述

所以我最近开始进行一些组装,并且我是一个初学者,所以我想知道是否有人可以澄清一些事情.我认为每个进程都有自己的一组寄存器,每个线程都可以修改这些寄存器,对吗?那么多个线程如何使用相同的寄存器而不引起冲突?还是每个线程都有自己的寄存器集?

So I've been getting into a bit of assembly lately and I'm a beginner so i was wondering if someone could clarify something. I take it every process has it's own set of registers, and each thread can modify these registers right?. How then do multiple threads use the same registers without causing clashes? Or does each thread have its own set of registers?

推荐答案

线程上下文切换涉及保存当前执行上下文的寄存器,并从开始切换到的执行上下文中加载具有已保存值的寄存器.(除其他事项外).因此,每个线程实际上都有自己的一组寄存器.由于ESP是寄存器之一,因此它也是自己的堆栈.

A thread context switch involves saving the registers of the current execution context, and loading the registers with saved values from execution context begin switched to. (among other things). So each thread effectively has its own set of registers. Also its own stack, since ESP is one of the registers.

对此进行思考的一种方式是,通过保存当前寄存器状态并以新状态加载寄存器来获取线程.如果这没有发生,那么它不是线程开关.如果您还要切换到另一组虚拟地址表,那么您拥有的是进程切换而不是线程切换.

One way of thinking about this is that you get threads by saving off the current register state, and loading the registers with a new state. If that isn't happening, then Its not a thread switch. If you are also switching to a different set of virtual address tables, then what you have is a process switch rather than a thread switch.

您说:

我认为每个进程都有自己的一组寄存器,每个线程都可以修改这些寄存器吗?

I take it every process has it's own set of registers, and each thread can modify these registers right?

但这并不完全正确.每个CPU内核都有一组寄存器.只要操作系统切换到其他线程,这些寄存器就会更改.但是在任何时候,只有一个线程在CPU内核中执行.进程实际上并没有自己的寄存器,进程拥有自己的线程(或至少一个线程),并且线程具有寄存器,或者是在线程等待CPU内核可用时保留寄存器值的地方.继续.

But this isn't quite right. Each CPU core has a single set of registers. These registers are changed whenever the OS switches to a different thread. But there is only one thread executing in a CPU core at any one time. Processes don't really have their own registers, processes own threads (or at least one thread), and threads have registers, or rather a place to keep the values for the registers while the thread is waiting for a CPU core to be available to run on.

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

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