The challenges of demand paging in memory management, focusing on the importance of frame-allocation and page-replacement algorithms. It covers the concept of page replacement, the need for it, and introduces various page replacement algorithms such as fifo, optimal, and lru. The document also explains belady's anomaly and the importance of evaluating algorithms based on their page fault rates.
Download Understanding Page Replacement Algorithms & Challenges in Demand Paging and more Study notes Operating Systems in PDF only on Docsity!
MEMORY MANAGEMENT
Challenges of Demand Paging
(^) It is important to develop a frame-allocation algorithm and a page-replacement algorithm.
(^) If we have multiple processes in memory, we must decide how many frames to allocate to each process.
(^) Further, when page replacement is required, we must select the frames that are to be replaced.
Need For Page
Replacement
Basic Page Replacement
Find the location of the desired page on disk
Find a free frame:
(^) If there is a free frame, use it
(^) If there is no free frame, use a page replacement algorithm to select a victim frame
(^) Write the victim frame to the disk change the frame and page tables accordingly.
Read the desired page into the (newly) free frame. Update the page and frame tables.
Restart the process
Page Replacement
(^) There are many different page-replacement algorithms.
(^) Every operating system probably has its own replacement scheme.
(^) How do we select a particular replacement algorithm?
(^) In general, we want the one with the lowest page- fault rate.
Page Replacement
(^) We evaluate an algorithm by running it on a particular string of memory references and computing the number of page faults.
(^) The string of memory references is called a reference string.
(^) To determine the number of page faults for a particular reference string and page-replacement algorithm, we also need to know the number of page frames available.
Page Replacement Algorithms
(^) FIFO Page Replacement Algorithm
(^) Optimal Page Replacement Algorithm
(^) Least Recently Used (LRU) Algorithm
First-In-First-Out (FIFO)
Algorithm
(^) This policy simply removes pages in the order they arrived in the main memory.
(^) When a page must be replaced, the oldest page is chosen.
First-In-First-Out (FIFO)
Algorithm
(^) The FIFO page-replacement algorithm is easy to understand and program.
(^) However, its performance is not always good.
(^) On the one hand, the page replaced may be an initialization module that was used a long time ago and is no longer needed.