Abstract
- A page fault occurs when a memory page is not currently mapped to a memory frame in the page table. This means that the data from the corresponding memory page can’t be found in the main memory. The CPU can only proceed with the task after the required data is fetched from the main memory
Minor Page Fault
- Also known as a soft fault
- The requested page is present in main memory but not currently accessible to the process
Important
Quick resolution: Minor page faults are handled quickly by the kernel with minimal impact on performance. Kernel just needs to update the page table to map the page correctly.
Common occurrence: Minor page faults are a normal part of virtual memory management and occur frequently during program execution.
Major Page Fault
- Also known as hard page fault
- The page table entry exists in page table, but it points to the secondary storage (flash memory or hard disk)
How to handle?
The corresponding data needs to be transferred from secondary storage into main memory for use by by the CPU. This process, known as paging, causes a significant performance slowdown.
Lazy Memory Allocation
- Memory frames are not allocated until they are actually needed. Therefore, the memory page is not mapped to data in main memory or the secondary storage
Why this will cause page fault?
The kernel must find free space in main memory, allocate memory frames, and update the page table. This is often caused by demand paging (where pages are loaded only when needed) and can result in slower access times.
It also increases the risk of runtime allocation errors, making the application more likely to crash during execution.
Why we want lazy allocation?
By delaying the actual allocation, we speed up startup time & eliminate allocation entirely if it isn’t used.