Virtual Memory

An OS handles a page fault trap as follows:

  1. The memory address requested is first checked, to make sure it was a valid memory request (that is, that this address doesn't belong to another program.)
  2. If the reference was invalid, the program is terminated. Otherwise, the page must be paged in (= brought from disk to memory.)
  3. A free frame is located, possibly from a free-frame list.
  4. A disk operation is scheduled to bring in the necessary page from disk, during which the program's execution is paused.
  5. When the copy from disk finishes, the program's page table is updated with the new frame number, and the invalid bit is changed to indicate that this is now a valid page reference.
  6. The instruction that caused the page fault must now be restarted from the beginning, and this program will continue executing on the CPU.