Page Replacement
The procedure of page replacement goes as follows:
- The operating system finds the location on disk of the page that is to be loaded.
- The operating system searches for a free frame.
- If there is a free frame, use it.
- If there is no free frame, use a page-replacement algorithm to select an existing frame to be replaced, known as the victim frame.
- Copy the data of the victim frame to disk in order to free the frame up.
- Change all related page tables to indicate that this page is no longer in memory.
- 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.
- Resume the execution of the process that was waiting for this page.