Demand Paging

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 process.)
  2. If the reference was invalid, the process 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 process is blocking (= waiting).
  5. When the copy from disk finishes, the process'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 process will continue executing on the CPU.