13 Dec 2019

  • December 13, 2019
  • Amitraj
What is a Page Fault?

If the referred page is not present in the main memory then there will be a miss and the concept is called Page miss or page fault.


The CPU has to access the missed page from the secondary memory. If the number of page fault is very high then the effective access time of the system will become very high.



Page Replacement

Page replacement is a process of swapping out an existing page from the frame of a main memory and replacing it with the required page.

-> Page replacement is required when-

1. All the frames of main memory are already occupied.

2. Thus, a page has to be replaced to create a room for the required page.




Page Replacement Algorithms

Page replacement algorithms help to decide which page must be swapped out from the main memory to create a room for the incoming page.


Different page replacement algorithms are:-


1. FIFO Page Replacement Algorithm
2. LIFO Page Replacement Algorithm
3. LRU Page Replacement Algorithm
4. Optimal Page Replacement Algorithm
5. Random Page Replacement Algorithm


*A good page replacement algorithm is one that minimizes the number of page faults.



1. FIFO Page Replacement Algorithm:-
-> As the name suggests, this algorithm works on the principle of “First in First out“.

-> It replaces the oldest page that has been present in the main memory for the longest time.

-> It is implemented by keeping track of all the pages in a queue.


2. LIFO Page Replacement Algorithm-
-> As the name suggests, this algorithm works on the principle of “Last in First out“.

-> It replaces the newest page that arrived at last in the main memory.

-> It is implemented by keeping track of all the pages in a stack.


NOTE:-  Only frame is used for page replacement during entire procedure after all the frames get occupied.



3. LRU Page Replacement Algorithm:-
-> As the name suggests, this algorithm works on the principle of “Least Recently Used“.

-> It replaces the page that has not been referred by the CPU for the longest time.


4. Optimal Page Replacement Algorithm-
-> This algorithm replaces the page that will not be referred by the CPU in future for the longest time.

-> It is practically impossible to implement this algorithm.

-> This is because the pages that will not be used in future for the longest time can not be predicted.

-> However, it is the best known algorithm and gives the least number of page faults.

-> Hence, it is used as a performance measure criterion for other algorithms.


5. Random Page Replacement Algorithm:-
-> As the name suggests, this algorithm randomly replaces any page.

-> So, this algorithm may behave like any other algorithm like FIFO, LIFO, LRU, Optimal etc.


Translate

Popular Posts