Assignment 4
Assignment 4
Description:
FIFO is an algorithm where page replacement occurs based on the "first-in, first-out" principle. This
means the page that has been in memory the longest is replaced first.
This algorithm is simple to implement and requires minimal additional data (e.g., a list or queue to
track the order).
Advantages:
1. Easy to implement.
Disadvantages:
1. Can lead to frequent page faults, especially with sequences where older pages continue to be used
(Belady's anomaly).
Example:
Step-by-step execution:
LIFO is an algorithm that replaces the page most recently added to memory. This is the opposite of
FIFO.
Its implementation relies on the "stack" data structure, where the last added page is the first to be
removed.
Advantages:
2. Can be efficient in some cases where recently added pages are no longer needed.
Disadvantages:
1. Often leads to a high number of page faults, as it frequently replaces just-added pages.
2. Impractical for most real-world systems as it ignores the access patterns of pages.
Example:
Step-by-step execution:
1. FIFO replaces pages based on their arrival time, which can lead to
Belady's anomaly and a higher number of page faults.
2. LIFO replaces the most recently added pages, often making it less
effective in real-world scenarios as it frequently evicts relevant data.