页面错误可能涉及也可能不涉及使该页面可用的辅助存储访问,这意味着什么

页面错误可能涉及也可能不涉及使该页面可用的辅助存储访问,这意味着什么

从联机帮助页top

nMaj  --  Major Page Fault Count
           The number of major page faults that have occurred for a task.  A
           page fault occurs when a process attempts to read from or write
           to a virtual page that is not currently present in its address
           space.  **A major page fault is when auxiliary storage access is
           involved in making that page available.**

nMin  --  Minor Page Fault count
           The number of minor page faults that have occurred for a task.  A
           page fault occurs when a process attempts to read from or write
           to a virtual page that is not currently present in its address
           space.  **A minor page fault does not involve auxiliary storage
           access in making that page available.**

如果我是正确的,处理页面错误就是将物理内存中丢失的所需数据从交换区传输到物理内存。交换是存储的一部分,例如硬盘驱动器或 SSD。那么页面错误可能会或可能不会是什么意思?涉及辅助存储访问以使该页面可用

谢谢。

答案1

只有主要页面错误涉及辅助存储(IE从磁盘读取,无论是从交换区还是其他地方,例如当以二进制形式分页时)。

次要页面错误是无需从磁盘读取即可解决的错误:

  • 涉及已映射到内存中其他位置的数据的页面错误(例如可以在进程之间共享内存)
  • 新分配内存的页面错误(使用全零页面和写时复制分配)
  • 在某些情况下,已标记为调出但尚未调出的数据

(这并不详尽)。

答案2

例如,当数据或代码位于内存中但未映射到进程时,就会发生轻微页面​​错误。

考虑一个被另一个进程使用的共享库。您的进程想要加载相同的库,因此 ld (我认为通过 libc/glibc?)问题会生成页面错误。内核知道数据已经在内存中,并将其映射到进程。无需从磁盘加载它...

相关内容