Page Fault
Important
Question
What if a piece of data is on disk rather than in memory?
- If the Page Table indicates that the virtual address is not in memory
A hardware exception will be generated (captured by the OS)
- The current process suspends, others can resume
- The OS moves the data to memory and resumes the suspended process
Page faults are generated when the Page Table tells the OS that the page is on disk
- The CPU then generates a Page Fault Exception
- The OS must then retrieve the data from the disk
- The OS chooses a page to evict from RAM and write to disk
- The OS then reads the page from disk and puts it in RAM
- The OS then updates the Page Table to map the new page - The OS then jumps back to the instruction that caused the page fault
- This time won't cause a page fault since the page has been loaded into memory