Go Back

A Quick Abstract:

1. Introduction to Page Replacement:

Page replacement algorithms play a vital role in managing memory in virtual memory systems. Both LRU and MRU are strategies that consider the recent usage history of pages to determine which one to replace when a page fault occurs.

2. LRU (Least Recently Used) Page Replacement Algorithm:

Working:

Maintain a record of the order in which pages are accessed.

When a page fault occurs:

Replace the page that has not been used for the longest period.

Advantages:

Effective in capturing temporal locality.

Disadvantages:

Requires a mechanism to track page access history, which can be resource-intensive.

3. MRU (Most Recently Used) Page Replacement Algorithm:

Working:

Maintain a record of the order in which pages are accessed.

When a page fault occurs:

Replace the page that has been used most recently.

Advantages:

Simplicity in implementation.

Suitable for environments where recently used pages are more likely to be used again.

Disadvantages:

May not perform optimally in scenarios with temporal locality.

4. Example Scenario:

Consider a memory system with three frames (A, B, C) and a sequence of page requests: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3.

LRU:

Initial state: | - | - | - |

Page 1 is requested: | 1 | - | - |

Page 2 is requested: | 1 | 2 | - |

Page 3 is requested: | 1 | 2 | 3 |

Page 4 is requested: | 4 | 2 | 3 | (Page 1 is the least recently used, so it is replaced)

... and so on.

MRU:

Initial state: | - | - | - |

Page 1 is requested: | 1 | - | - |

Page 2 is requested: | 1 | 2 | - |

Page 3 is requested: | 1 | 2 | 3 |

Page 4 is requested: | 1 | 2 | 4 | (Page 3 is the most recently used, so it is replaced)

... and so on.

5. Conclusion:

LRU and MRU are page replacement algorithms that focus on the recency of page usage. While LRU is effective in capturing temporal locality, it requires additional mechanisms for maintaining access history. MRU, on the other hand, is simpler but may not perform optimally in scenarios with temporal locality.

Notes From The Slides:



Least Recently Used (LRU) Algorithm

Least Recently Used (LRU) Algorithm

LRU Algorithm (Cont.)

LRU Algorithm (Cont.)

LRU Approximation Algorithms

LRU Approximation Algorithms (cont.)


Second-chance Algorithm

Enhanced Second-Chance Algorithm

Most Recently Used (MRU) Algorithm