从用户模式CPU切换到内核模式:究竟是做什么?它是如何使这种转变? [英] CPU Switches from User mode to Kernel Mode : What exactly does it do? How does it makes this transition?
问题描述
CPU 从用户模式切换到内核模式:究竟是做什么?它是如何使这一过渡?
CPU Switches from User mode to Kernel Mode : What exactly does it do? How does it makes this transition?
编辑:
即使是架构相关的,请给我一个答案。该架构是由你。告诉我你知道的架构。
Even if it is architecture dependent please provide me with an answer. The architecture is up to you. Tell me for the architecture you know about.
我要得到什么东西都将在它参与的想法。
I want to get an idea about what all things will be involved in it.
推荐答案
请注意:这主要是为x86架构有关。这里有一个稍微简化的解释。
Note: this is mostly relevant to x86 architecture. Here's a somewhat simplified explanation.
的过渡通常是由下列之一引起的:
The transition is usually caused by one of the following:
- 故障(如页面错误或其他异常引起的通过执行一个指令)
- 中断(例如键盘中断或I / O整理)
- 陷阱(例如一个系统调用)
什么通常的情况是,系统检查中断描述符表(IDT)。每个异常(中断,故障等)具有与其相关联的号码,用来索引到此表
What normally happens is that system checks the Interrupt Descriptor Table (IDT). Each exception (interrupt, fault, etc.) has a number associated with it which is used to index into this table.
从这个表中的CPU可以判断中断处理程序运行。
From this table the CPU can determine the interrupt handler to run.
作为过渡以下变化(一般)生效的一部分:
As part of the transition the following changes (generally) take effect:
- 切换到内核堆栈
- EFLAGS保存
- code段选择和EIP被保存。
- 的堆栈段选择和堆栈指针保存
- 开始执行中断处理程序
- 的通用寄存器保存(处理程序的工作)
- 段选择更改为内核的人(处理程序的工作)
您在内核模式现在已经。
You're now in kernel mode.
希望有所帮助:)
这篇关于从用户模式CPU切换到内核模式:究竟是做什么?它是如何使这种转变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!