Operating System Fundamentals 59
Swapping Pages Whenever main memory (RAM) is full, or when a page is requested that is located in virtual memory,
the memory manager needs to swap old or unused pages from RAM into virtual memory in order to make space for the new pages being loaded. There area number of strategies used by the memory manager to handle this task. These strategies are often called
replacement policies. There are five main replacement policies that are used by operating systems
Random Replacement First In First Out (FIFO)
Second Chance Least Recently used Least Frequently Used Each of these replacement policies uses different algorithms for selecting pages to be swapped from RAM into the page file.
Random Replacement Replace pages in main memory randomly.
On the average, does notwork well.
FIFO Uses a queue data structure to keep track of the pages in main memory. Oldest page at the front (head) and newest page at the back (tail. Always replace (get rid of) the oldest page. Does not always work, because the oldest page may still be used by the process.
Second Chance Another version of FIFO to address the problem of FIFO. All pages in the page table are tracked to see if they have been referenced recently by a process. A Reference (R) bit for each page is used for this purpose o R = 1 when the page is being referenced. o R = 0 when the page has not been used after a time period. o The OS will periodically check the (R) bit for each page and move the pages those R) = 1 to the tail of the queue thus given and chance.
Share with your friends: