Page Replacement

The procedure of page replacement goes as follows:

  1. The operating system finds the location on disk of the page that is to be loaded.
  2. The operating system searches for a free frame.
    1. If there is a free frame, use it.
    2. If there is no free frame, use a page-replacement algorithm to select an existing frame to be replaced, known as the victim frame.
      1. Copy the data of the victim frame to disk in order to free the frame up.
      2. Change all related page tables to indicate that this page is no longer in memory.
  3. Read in the desired page from disk and store it in the memory frame that was freed. Adjust all related page and frame tables to indicate the change.
  4. Resume the execution of the process that was waiting for this page.