Optimal Page Replacement
The process in an operating system occupies some dedicated memory. This memory is further divided into chunks called pages. These pages are brought from secondary memory to the primary memory as the CPU demands them. This method is known as page swapping and is done through an algorithm.
To fulfill the demand of the most frequently used pages, the operating systems keep these pages in the primary memory. Pages that not have been used since a long time are replaced with the most frequently used pages under the method called as Optimal Page Replacement technique.
The approach can be best explained by the below reference string and the frame size.
- Read Also – Optimal page replacement in python
- Read Also – Optimal Page LRU in C++
- Read Also – Optimal page LRU in C
Reference String: 4 6 7 8 5 6 7
The diagrammatic representation above states the order in which the stack will be filled as per the demands in the primary memory. In the case of a page fault, the least recently used page is replaced with the pager which in immediate demand.
Algorithm for Optimal Page Replacement
Step 1: Push the first page in the stack as per the memory demand.
Push the second page as per the memory demand.
Push the third page until the memory is full.
As the queue is full, the page which is least recently used is popped.
repeat step 4 until the page demand continues and until the processing is over.
Terminate the program.
- Memory Management Introduction
- Partition Allocation Method
- Buddy- System Allocator
- Types of Paging
- Mapping Virtual address to Physical Address.
- Virtual Memory
- Demand Paging
- Implementation of Demand paging and page fault
- Page Replacement Algorithms
- Belady’s Anomaly
- Static vs Dynamic Loading
- Static vs Dynamic Linking
- Translational Look Aside Buffer
- Process Address Space
- Difference between Segmentation and Paging