Page Replacement Methods 1 Submitted By MD Sazid Zamil (213015018) Romn Ahmed Shohag (213015017) Submitted To Mahbubur Rahman Lecturer, Green University of Bangladesh
I n tro d u ct i on 2 Page replacement is a memory management scheme that decides which memory pages to swap out when a memory page needs to be allocated. Purpose : To ensure efficient utilization of memory and improve system performance. Context : Used in systems with virtual memory to extend the apparent amount of RAM by using disk space. Fig 1: Page Replacement
Necessity of Page Replacement Limited Physical Memory : RAM is finite and can be quickly exhausted. Virtual Memory : Using disk space to extend RAM, allowing more applications to run. Page Faults : Occur when required pages are not in RAM, causing delays. Efficient Memory Utilization : Keeps frequently/recently used pages in RAM, reducing page faults. System Performance : Fewer page faults lead to faster application performance and responsiveness. Multitasking : Optimizes memory for concurrent running of multiple applications. Fair Resource Allocation : Ensures all processes get a fair share of memory, maintaining stability. 3
Algorithms This algorithm helps to decide which pages must be swapped out from the main memory in order to create a room for the incoming page. This Algorithm wants the lowest page-fault rate. 4 Fig 2 : Various Page Replacement algorithms used in the Operating system
First In First Out (FIFO) The operating system keeps track of all pages in the memory in a queue, the oldest page is in the front of the queue. When a page needs to be replaced page in the front of the queue is selected for removal. Advantages : Simple and easy to implement. Disadvantages : Can lead to high page fault rates ( Belady's anomaly) 5 Example 1 Initially, all slots are empty, so when 1, 3, 0 came they are allocated to the empty slots —> 3 Page Faults. when 3 comes, it is already in memory so —> 0 Page Faults. Then 5 comes, it is not available in memory so it replaces the oldest page slot i.e 1. —>1 Page Fault. 6 comes, it is also not available in memory so it replaces the oldest page slot i.e 3 —>1 Page Fault. Finally, when 3 come it is not available so it replaces 0 1 page fault. Fig 3 : First In First Out (FIFO)
Optimal Page Replacement Advantages : Produces the lowest possible page fault rate. Disadvantages : Requires future knowledge of the reference string (theoretical). 6 Fig 4 : Optimal Page Replacement
Least Recently Used (LRU) Advantages : Better performance than FIFO in many cases. Disadvantages: Difficult to implement and requires keeping track of page usage. 7 Fig 5 : Least Recently Used (LRU)
Comparison of Algorithms Performance : Optimal < LRU < Clock < FIFO (in terms of page fault rates). Implementation Complexity : FIFO (simplest) < Clock < LRU < Optimal (most complex). Use Cases : FIFO : Simple systems with predictable workloads. LRU : Systems where recent history is a good predictor of future use. Optimal : Theoretical benchmark for comparison. Clock : Systems needing a balance between performance and complexity. 8
Practical Considerations Workload Characteristics : Different algorithms perform better under different conditions. System Overhead : Balancing performance improvements with the cost of implementation. Adaptive Algorithms : Modern systems may adaptively switch algorithms based on workload. 9
The choice of page replacement algorithm can significantly impact system performance, making it crucial to select the right algorithm based on workload and system requirements. Conclusion 10
Refferences Books and Articles : "Operating System Concepts" by Silberschatz , Galvin, and Gagne "Modern Operating Systems" by Andrew S. Tanenbaum Online Resources : Wikipedia - Page Replacement Algorithms GeeksforGeeks - Page Replacement Algorithms studytonight.com/operating-system/page-replacement-algorithms-in-operating-system 11