Osy Micro
Osy Micro
A
MICRO PROJECT ON
LRU (Least Recently Used) Page Replacement Algorithm
Submitted To
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
IN THE PARTIAL FULFILLMENT OF THE REQUIRMENT FOR
DIPLOMA IN COMUTER ENGINEERING
SUBMITTED BY:
Mr. Dabholkar Sanchit Sachin
Miss. Jadhav Shruti Mahesh
Mr. Tawade Dayanand Santosh
Enrollment No:-
2201080293, 2201080294, 2201080295
Name of Guide:
Miss. Shinde . P. A.
MAHARASHTRA STATE
BOARD TECHNICAL EDUCATION
Certificate
This is to certify that Mr. Dabholkar Sanchit Sachin, Miss. Jadhav
Shruti Mahesh, Mr. Tawade Dayanand Santosh. Roll no: 3413, 3414,
3415 Of 5th Semester of diploma in Computer Engineering of Sahyadri
Polytechnic Sawarde (Code: 0108) has completed the Micro Project
satisfactorily in subject OSY(22516) for the academic year 2024-25 as
prescribed in the curriculum.
➢ Introduction:
If we use the recent past as an approximation of the near future,
then we would replace that page which has not been used for the
longest period of time. This is the least recently used algorithm.
LRU replacement associates with each page the time of its last
use. When a page is to be replaced. LRU chooses that page
which has not been used for the longest period of time.
We can think of this strategy as the optimal page-replacement
algorithm looking backward in time. rather than forward.
For example consider the following reference string, 7, 0, 1, 2,
0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0,1,7,0,1
By applying LRU, the first five faults are same as the optimal
replacement. When the reference to page 4 occurs, LRU sees
out of the three frames in memory, page 2 was used least
recently. The most recently used page is page 0, and just before
that page 3 was used.
Thus LRU replaces page 2, not knowing that it is about to be
used. When fault for page 2 occurs, LRU replaces page 3. Since
of the three pages in memory (0, 3, 4) page 3 is the least
recently used. No. of page faults = 12.
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7 7 7 2 2 4 4 4 0 1 1 1
0 0 0 0 0 0 3 3 3 0 0
1 1 3 3 2 2 2 2 2 7
➢ Reference string
4 7 0 7 1 0 1 2 1 2 7 1 2
2 7
1 2 a b
a
0 1 a
7 0
4 4
Stack before a Stack after b
Use of a stack to Record the most recent page references
➢ Two implementation of LRU are:
1. Counters: Each page table entry has a time of use register and
adds to the CPU a logical clock or counter. The clock is
incremented for every memory reference. Whenever a reference
to a page is made, the contents of the clock register are copied
to the time of use register in the page table for that page. Thus
we always have the "time" of the last reference to each page.
We replace the page with the smaller time value.
2. Stack: This implementation keeps a stack of page numbers.
Whenever a page is referenced. it is removed from the stack and
put on the top. Thus the top of the stack is always the most
recently used page and the bottom is the least recently used
page.
1 *1 1 1 *4 4 4 *5 5 5 *3 3 3
2 *2 2 2 *1 1 1 1 1 1 *4 4
3 *3 3 3 *2 2 2 2 2 2 *5
Page Fault ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
Total Page Faults 10.
➢ Conclusion:
Advantages of LRU Page Replacement Algorithm
Optimizes memory usage: The LRU algorithm keeps the pages
that are most frequently accessed in memory, which optimizes
memory usage and ensures that frequently used pages are
available quickly. Simple implementation: The LRU algorithm is
easy to understand and implement.
TEACHER EVALUATION SHEET