memoryvirtual-memoryfragmentationpage-fault

Is there a disk access in every page fault?


My question is (as stated) is there an access to the disk/virtual memory every time there is a page fault?

If not, in what cases is there no disk access?

(this is a general question about paging and not implementation dependent)

Thank you


Solution

  • There are some cases where a page fault will not trigger a disk access.

    A page fault is an exception triggered when a process requests a virtual address that is not mapped by the MMU (memory-management unit) to a physical page. If the page is not resident anywhere in physical memory (RAM), the virtual address is valid, and page data that exists in the backing store (i.e. disk) is required, the page fault handler will trigger an access to the disk. This situation is usually classified as a hard page fault or major page fault.

    During a minor page fault or soft page fault, the requested physical page is not mapped in the virtual address space of the process by the MMU, but no disk access is necessary, for a few possible reasons:

    Cases where an address that is not a part of the virtual address space is requested can also trigger a page fault, usually called an invalid page fault. If a process attempts to reference a NULL pointer, for example, the page fault handler will usually trigger a segmentation fault. (Invalid page faults don't necessarily always occur due to a page protection violation -- this is just any example of one case).

    (I referenced the Wikipedia page for Page fault and would definitely recommend it as a concise introduction to page faults!)