IA mode和windows mode的比较

来源:互联网 发布:linux下iperf使用方法 编辑:程序博客网 时间:2024/06/11 18:54

Windows internal

 


kernel mode和user mode

Windows下着两种mode是基于intel x86/x64 的privilege level 0 和level 3.x86/x64提供了4个level/ring: ring 0 - 3. windows 只使用了2个因为以前的OS只用了2个priviledge level,比如Compaq Alpha, Silicom Gaphics MIPS。

这两种mode的切换需要CPU的支持和参与。

 

 

摘自wikibooks的一段:

"When a program wants to call a Windows API function1, it triggers an interrupt2 which causes the CPU to switch to kernel mode and begin executing the desired API function. When the API function has finished processing, it switches back to user mode and resumes execution of the program. This is because API functions like ReadProcessMemory cannot work in user mode; the program can't access other programs' memory. In kernel mode, however, the API function can read any memory region without restriction.

1. Actually, Windows API functions eventually call a different API: the Native API. This is the API used by the Windows NT family of kernels. This is when the CPU switches to kernel-mode.

2. Modern CPUs have special, faster instructions for system calls, such as sysenter and sysexit on x86. These instructions cause the CPU to switch to ring 0, and then begin executing a handler set up by the operating system."



real mode 和 protected mode

Intel CPU 从80286开始引入protected mode.相对于real mode,protected mode可以访问更大的地址空间,提供分页,支持虚拟地址。

 

 

【AR】:这两种mode分类的层次。

原创粉丝点击