如何从用户模式切换到内核模式? [英] How to switch from user mode to kernel mode?

查看:602
本文介绍了如何从用户模式切换到内核模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Linux内核,但是我不明白如何在Linux中从用户模式切换到内核模式.它是如何工作的?您能给我一些建议还是给我一些链接以供参考或有关这本书的书吗?

I'm learning about the Linux kernel but I don't understand how to switch from user mode to kernel mode in Linux. How does it work? Could you give me some advice or give me some link to refer or some book about this?

推荐答案

在正常操作期间,用户空间应用程序可以显式启动向内核模式的切换的唯一方法是通过进行系统调用,例如编写等.

The only way an user space application can explicitly initiate a switch to kernel mode during normal operation is by making an system call such as open, read, write etc.

每当用户应用程序使用适当的参数调用这些系统调用API时,都会触发软件中断/异常(SWI).

Whenever a user application calls these system call APIs with appropriate parameters, a software interrupt/exception(SWI) is triggered.

作为此SWI的结果,代码执行的控制从用户应用程序跳转到OS提供的中断向量表[IVT]中的预定义位置.

As a result of this SWI, the control of the code execution jumps from the user application to a predefined location in the Interrupt Vector Table [IVT] provided by the OS.

此IVT包含SWI异常处理程序例程的地址,该例程执行将用户应用程序切换到内核模式并代表用户进程开始执行内核指令所需的所有必要步骤.

This IVT contains an adress for the SWI exception handler routine, which performs all the necessary steps required to switch the user application to kernel mode and start executing kernel instructions on behalf of user process.

这篇关于如何从用户模式切换到内核模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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