微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

用户空间进程是否抢占了内核线程?

目前我正在阅读“理解Linux内核,第3版”,在第22页,我可以阅读:

In the simplest case,the cpu executes a kernel control path sequentially from the
first instruction to the last. When one of the following events occurs,however,the
cpu interleaves the kernel control paths:

  • A process executing in User Mode invokes a system call,and the corresponding
    kernel control path verifies that the request cannot be satisfied immediately; it
    then invokes the scheduler to select a new process to run. As a result,a process
    switch occurs. The first kernel control path is left unfinished,and the cpu
    resumes the execution of some other kernel control path. In this case,the two
    control paths are executed on behalf of two different processes.

内核控制路径可以从进行系统调用用户空间进程中断?
我认为优先级非常重要:

>中断
>内核线程
>用户空间流程

我检查了勘误表,但却找不到任何相关信息.

最佳答案
你对优先权清单是正确的,但这本书试图说的是(我认为):

>当(用户)进程进行系统调用时,内核会代表它开始执行.
>如果系统调用可以完成(内核控制路径没有遇到障碍),那么它通常会直接返回到调用进程 – 想想getpid()函数调用.
>另一方面,如果系统调用无法完成(例如,因为磁盘系统必须在将数据返回到调用进程之前将块读入内核缓冲池),则调度程序用于选择要运行的新进程 – 抢占(代表用户运行的控制的内核线程)用户进程.
>在适当的时候,原始系统调用将能够继续,并且原始(代表运行的控制的内核线程)用户进程将能够继续并最终完成,将控制权返回给运行的用户空间进程在用户空间而不是在内核中.

所以“不”:不是’内核路径可以从进行系统调用用户空间进程中断’的情况.

代表用户空间进程执行系统调用时,内核路径可能会被中断,原因是:发生中断,或者内核路径必须等待资源变为可用,或者……

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐