0% found this document useful (0 votes)
2 views

Assignment 4

FIFO and LIFO are page replacement algorithms that manage memory by replacing pages based on their arrival time and recency, respectively. FIFO can lead to higher page faults due to Belady's anomaly, while LIFO often evicts relevant data, making it less effective in real-world scenarios. Advanced algorithms like LRU or Optimal are suggested for better performance as they consider access patterns.

Uploaded by

cybereast.kz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Assignment 4

FIFO and LIFO are page replacement algorithms that manage memory by replacing pages based on their arrival time and recency, respectively. FIFO can lead to higher page faults due to Belady's anomaly, while LIFO often evicts relevant data, making it less effective in real-world scenarios. Advanced algorithms like LRU or Optimal are suggested for better performance as they consider access patterns.

Uploaded by

cybereast.kz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

FIFO (First-In-First-Out)

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.

2. Requires minimal computational resources.

Disadvantages:

1. Can lead to frequent page faults, especially with sequences where older pages continue to be used
(Belady's anomaly).

2. Does not account for the frequency or recency of page usage.

Example:

 Page sequence: [1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5]


 Memory size: 3

Step-by-step execution:

1. Memory starts empty. Add 1, 2, and 3 (3 page faults): [1, 2, 3].


2. Request 4. Replace the oldest page (1): [4, 2, 3].
3. Request 1. Replace the oldest page (2): [4, 1, 3].
4. Request 2. Replace the oldest page (3): [4, 1, 2].
5. Request 5. Replace the oldest page (4): [5, 1, 2].

Total page faults: 9.


LIFO (Last-In-First-Out)
Description:

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:

1. Simple to implement, similar to FIFO.

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:

 Page sequence: [1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5]


 Memory size: 3

Step-by-step execution:

1. Memory starts empty. Add 1, 2, and 3 (3 page faults): [1, 2, 3].


2. Request 4. Replace the most recently added page (3): [1, 2, 4].
3. Request 1. No replacement needed (already in memory).
4. Request 2. No replacement needed (already in memory).
5. Request 5. Replace the most recently added page (4): [1, 2, 5].
6. Request 3. Replace the most recently added page (5): [1, 2, 3] 7.
7. Total page faults: 8.
Conclusion

Page replacement algorithms like FIFO and LIFO are simple to


implement and demonstrate basic memory management strategies.
However:

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.

To achieve better performance in practical systems, more advanced


algorithms such as LRU or Optimal are recommended, as they consider
access patterns and page usage.

You might also like