process - 没有上下文切换的系统调用?

标签 process linux-kernel context-switch

当我遇到这个时,我刚刚在我的操作系统书籍中阅读了 Linux 如何工作的内容..

[...] the kernel is created as a single, monolitic binary. The main reason is to improve performance. Because all kernel code and data structures are kept in a single address space, no context switches are necessary when a process calls an operating-system function or when a hardware interrup is delivered.

这对我来说听起来相当惊人,当然它必须在运行到内核模式来处理中断之前存储进程的上下文。但是好吧,我现在就买它。有几页在描述进程的调度上下文时说:

Both system calls and interrups that occur while the process is executing will use this stack.

“这个堆栈”是内核存储进程寄存器等的地方。

这不是与第一句话直接矛盾吗?我是否误解了它?

最佳答案

我认为第一句话是指单片内核和 microkernel 之间的差异.

Linux 是整体的,其所有内核组件(设备驱动程序、调度程序、VM 管理器)都运行在 ring 0 。因此,在执行系统调用和处理中断时不需要上下文切换。

对比微内核,其中设备驱动程序和 IPC 提供程序等组件在 user space 中运行,在环 0 之外。因此,该架构在执行系统调用(因为执行模块可能驻留在用户空间)和处理中断(将中断中继到设备驱动程序)时需要额外的上下文切换。

关于process - 没有上下文切换的系统调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8878557/

相关文章:

node.js - 获取node.js中所有嵌套子进程的标准输出

c - 如何在内核代码中获取子进程列表

linux - 跟踪 Linux 上的上下文切换

linux - 为内核设置构建选项

c - 在 Linux 中监视上下文切换

process - 进程调度上下文中调度程序和调度程序有什么区别

process - 贵公司收集哪些统计数据来定义代码/软件产品质量

linux - Linux 上的 killproc 和 pidofproc

python - 来自 Process 的简单 wxPython post 事件

c - 如何在 Linux Kernel 3.8.0 中修改 task_struct