LIFO

Downward Arrow

About

LIFO

Stands for "Last In, First Out." LIFO is an algorithm which follows processing of data in which the last items entered are the first to be removed. Thus the new element is inserted above the existing element. The operating system keeps track of all pages in the memory in a form of stack, the newest page is on the top of the stack. When a page needs to be replaced, page on the top of the stack is selected for removal first.


Advantages

  1. LIFO makes it easier to replace the newest page that arrived at last in the main memory.

  2. Simple data structures are used.

  3. Highly efficient.

Disadvantages

  1. As LIFO follows last in first out so it makes it time consuming to execute tasks which were scheduled first.

Algorithm

  1. LIFO algorithm can be implemented by creating a stack to store all pages in memory.

  2. Now maintain a stack of all pages currently in main memory and remove the page that is at the top of the stack at the linked list.

Implementation

Reference String:
Frames: