In: Computer Science
Write algorithm for LIFO (Last In First Out) Page Replacement Algorithm
In page replacement algorithm first, everyone should know about the concepts of Page hit, Page fault, Page reference string
Basically remembers one think that main memory is small so we need efficiently get the page into CPU.
Page hit- Suppose CPU sends a request for a page and we got a page in first memory then called it as Page hit.
Page fault - Same scenario, If CPU sends a request for a page and we can not get in first memory so we need to get it from the secondary memory so that is called a page fault.
Page reference string:- In this, every number indicates a page number.
Algorithm:
1) This algorithm works on "LAST IN FIRST OUT"
2) So, now it replaces the newest page which is coming at last in the main memory.
3) Remove the last element and other elements mention as it is. (If the next number is available there then make it as page hit)
4) Now, if the page reference string is not equal to elements then put the page reference number in place at the last.
5) It means that implemented by keeping track of all the pages in the stack.
6) now the important thing is that if all the frames get occupied during the above procedure then the only frame is used for the page replacement.