引起pagefault的原因
阅读原文时间:2021年04月20日阅读:1

A page fault is a trap to the software raised by the hardware when a program accesses a page that is mapped in the virtual address space, but not loaded in physical memory.

  • Reason for Fault - Result
  • Accessing a page that isn’t resident in memory but is on disk in a page file or a mapped file - Allocate a physical page, and read the desired page from disk and into the relevant working set
  • Accessing a page that is on the standby or modified list - Transition the page to the relevant process, session, or system working set
  • Accessing a demand-zero page - Add a zero-filled page to the relevant working set
  • Writing to a copy-on-write page - Make process-private (or session-private) copy of page, and replace original in process or system working set

Page faults can occur for a variety of reasons, as you can see above. Only one of them has to do with reading from the disk. If you try to allocate a block from the heap and the heap manager allocates new pages, then accesses those pages, you'll get a demand-zero page fault. If you try to hook a function in kernel32 by writing to kernel32's pages, you'll get a copy-on-write fault because those pages are silently being copied so your changes don't affect other processes.

yet you'll see soft page faults when memory is being shared between processes. Basically, if you have a memory-mapped file shared between two processes, when the second process loads the memory-mapped file, soft page faults are generated - the memory is already in physical RAM, but the operating system needs to fix up the memory manager's tables so that the virtual memory address in your process points to the correct physical page.
详细:http://stackoverflow.com/questions/5684365/what-causes-page-faults

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章