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
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:
The page could be resident in physical memory, even if it isn’t mapped by the process. The page may be part of shared memory and mapped by another process, or the page could not currently be mapped by any process, but in physical memory and not yet written to disk or erased.
Some operating systems have the concept of a “working set” of pages that are mapped at a given time for a process, and will set an upper limit on the number of pages that can be part of the working set. Pages may be removed from the working set of a process when it is determined that the working set of the process has grown too large, but remain unmodified in the free page list long enough to be requested and mapped again.
The page fault could also be a demand-zero fault — a demand-zero fault can be satisfied by allocating a free page in physical memory and setting its contents to all 0’s, so no disk access is necessary.
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!)