
4 minute read
Page Replacement Algorithms in OS with Examples and Policies
Definition: Page replacement policies determine which type of page should be replaced, but these page replacement strategies are only implemented when the requested page does not exist in the primary memory. In a computer system, managing memory efficiently is crucial for optimal performance. Here, we will explain all the key page replacement algorithms used in operating systems.
Why to Need of Page Replacement Algorithms?
Page Replacement Algorithms play vital role in the virtual memory management, because on the base of those Pages replacement policies can be specified that which memory block (page) should be swap out, arising memory space for needed page. Main objective of all Page replacement policies are to decrease the maximum number of page faults.
Mobile operating system Page Fault – Page fault means memory error, and page fault occurs when currently programs try to access memory page for mapping into virtual address space. But, it is not able to load into physical memory then it is known as “Page Fault”.
Types of Page Replacement Algorithms
There are various page replacement techniques, and we will explain each one
FIFO Page Replacement Algorithm
LIFO Page Replacement Algorithm
LRU Page Replacement Algorithm
Optimal Page Replacement Algorithm
Random Page Replacement Algorithm
FIFO Page Replacement Algorithm
This page replacement algorithm is very easy and simple because it is based on the “First In First Out” (FIFO) principle. In this method, the operating system uses a queue to store information about all the pages in the computer memory. According to the FIFO principle, the oldest page is replaced from the front of the queue, while the most recent page is added at the rear.
In Multi Core systems, where multiple processors handle several tasks simultaneously, efficient page replacement like FIFO can help manage memory across cores more effectively, ensuring smooth operation and performance.
Advantages of FIFO Page Replacement
It uses simple method, and easy to use.
It does not give more overhead.
Disadvantages of FIFO Page Replacement
Worst performance
Don’t use the frequency of last used time, just replace the oldest page.
Getting increase the page faults, while increasing page frames.
LIFO Page Replacement Algorithm
LIFO stands for “Last in First out“, and it performs all activities like LIFO principle. In this algorithm, newest page replaced which arrived at last in to primary memory, and it uses the stack for monitoring all pages.
LRU Page Replacement Algorithm
LRU stands for “Least Recently Used”, and it helps to operating system for searching such page that used over the short duration of time frame.
Mobile operating system This page replacement algorithm uses the counter along with even page, and that counter is known as aging registers.
LRU algorithm helps to select that page which is not needed for long life in to primary memory.
Advantages of LRU Page Replacement
Most efficient
It helps to open for full analysis.
Easy to identify the faulty page that not needed to long time.
Not getting more suffers from Belay's Anomaly.
Disadvantages of LRU Page Replacement
It has more complexity.
It has to need additional Data Structure.
More expensive
Computer component
Optimal Page Replacement Algorithm
Optimal Page Replacement Algorithm is very excellent page replacement policy because it helps to provide least number of page faults. For this reason, it have name the “OPT”, “Clairvoyant Replacement Algorithm”, and “Belay's optimal page policy”.
Features are
In this algorithm, such pages are replaced which are not needed to long life duration in future.
This algorithm does not produce more page faults.
It has very low page fault rate compare to other algorithm.
Advantages of Optimal Page Replacement
Easy to use
Easy to implement data structures for best result
Excellent efficiency
Less complexity
Less need to assistance
Disadvantages of Optimal Page Replacement
More time consumption
Need future awareness of program.
Difficult to error handling
Not easy to implement, because O/S not able to trace future request.
Random Page Replacement Algorithm
In this algorithm, randomly page can be replacing anytime, but it works like other page replacement policy such as FIFO, LIFO, LRU and Optimal.