LRU Algorithm
LRU Algorithm
GROUP MEMBERS:
M. MOHAMMED KISHORE
B.MUTHUKANNAN P. MUTHUKUMARAN
B. NAVEENKUMAR
M. NEELABHARATHY S. SABARI
PAGE REPLACEMENT
When a page fault occurs, the OS has to choose a page to
EXAMPLE
Reference string Reference string is the sequence of pages being referenced. If user has the following sequence of addresses 123, 215, 600, 1234, 76, 96.
PROBLEMS
Implementation is difficult Requires substantial hardware assistance - to determine an order for the frames defined by the time of last use.
IMPLEMENTATION
USING COUNTERS:
Each page-table entry is associated with a time-ofuse field and add to the CPU a logical clock or counter. The clock is incremented for every memory reference.
IMPLEMENTATION
DISADVANTAGES Requires a search of the page table to find the LRU page and a write to memory for each
memory access.
The times must also be maintained when page
USING STACK
IMPLEMENTATION
Whenever a page is referenced, it is removed from the stack and put on the top. the most recently used page is always at the top of the stack and the least recently used page is always at the bottom Because entries must be removed from the middle of the stack, it is best to implement using doubly linked list with a head pointer and a tail pointer. Removing a page and putting it on the top of the stack then requires changing six pointers at worst. Each update is a little more expensive There is no search for a replacement; the tail pointer points to the bottom of the stack, which is the LRU page.
EXAMPLE
IMPLEMENTATION
USING MATRIX For a machine with n page frames, the LRU hardware can maintain a matrix of n x n bits, initially all zero.
IMPLEMENTATION
EXAMPLE
Reference string: 0,1,2,3,2,1,0,3,2,3
THANK YOU