memory-management - 页面故障会导致故障处理重新安排吗?

标签 memory-management linux-kernel operating-system segmentation-fault swap

在Linux中,当进程尝试访问没有当前物理映射的页面(缺少页面表条目)时,将生成页面错误(由CPU)。这将导致Linux的页面错误处理程序被调用。如果此故障是“严重”故障,则意味着Linux必须从交换设备读取页面,在这种情况下,处理程序必须从实际磁盘读取。由于从磁盘读取是异步的(submit_bio),这会导致进程重新计划吗? (并在I/O完成后醒来吗?)

如果确实发生了重新计划,则对“schedule()”的调用在哪里?读取mm/swap_state.c中的代码并不能为我提供何时(或是否)发生这种情况的线索。

最佳答案

如果页面不在物理内存中,则该过程会阻塞,直到读取该页面为止,我认为您在错误的位置查找时间表应该在页面错误处理程序或其调用的任何函数中。在section 9.4. "Page Fault Exception Handler" of "Understanding the Linux Kernel" book中有更多信息,我引用:

The handle_mm_fault( ) function returns VM_FAULT_MINOR or VM_FAULT_MAJOR if it succeeded in allocating a new page frame for the process. The value VM_FAULT_MINOR indicates that the Page Fault has been handled without blocking the current process; this kind of Page Fault is called minor fault. The value VM_FAULT_MAJOR indicates that the Page Fault forced the current process to sleep

关于memory-management - 页面故障会导致故障处理重新安排吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13441732/

相关文章:

c - 删除链表后释放内存

c++ - "delete this"是个坏主意吗?

JavaScript 内存管理陷阱?

Linux libffi-3.0.11 安装问题

python - 为什么 os.scandir() 速度变慢/如何重组大目录?

c++ - 与 c 相比,为什么开发人员将 c/c++ 用于嵌入式系统而不是像 python 这样的高级语言?

c - 如何为 int C 哈希表分配内存?

c - 如何在 linux 中使用 ioctl 获取网关 ip 和名称服务器 ip

linux-kernel - Grub运行在什么模式下?

linux - inode存储在哪里?