0% found this document useful (0 votes)
3 views11 pages

Operating Systems Presentation

The document explains the Least Recently Used (LRU) page replacement algorithm, which replaces the page that has not been used for the longest time when a page fault occurs. It includes an example illustrating how page faults and hits are managed, along with a step-by-step algorithm for implementation. The document also outlines the advantages and disadvantages of the LRU method.

Uploaded by

22bcais046
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views11 pages

Operating Systems Presentation

The document explains the Least Recently Used (LRU) page replacement algorithm, which replaces the page that has not been used for the longest time when a page fault occurs. It includes an example illustrating how page faults and hits are managed, along with a step-by-step algorithm for implementation. The document also outlines the advantages and disadvantages of the LRU method.

Uploaded by

22bcais046
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

LAST RECENTLY USED

PAGE REPLACEMENT
R.K.SUSHMITA LAKSHME
LRU Page
Replacement
Whenever page fault occurs, least recently used
page will be replaced with a new page.
Page that is not utilized for longest time in
memory gets replaced.
PAGE FAULT: when a running program tries to
access a piece of memory that is not already
present in RAM.
PAGE HIT: Page is already present in memory .
LRU algorithm is used when a page fault occurs.
01 Table of Content

Meaning of LRU

Example

Algorithm
Example
Consider a reference string 1,2,1,0,3,0,4,2,4
2 0

1. All slots are empty so, pages 1,2 will be allocated to empty memory slots -> 2 page faults
will occur

121030424

2 1
2. Page 1 is referenced -> page hit -> NO page fault
3 1
121030424

2 1

3. Page 0 is referenced -> Allocated to third memory space -> page fault occurs

121030424

0 2 1
4. Page 3 is referenced -> no empty slot->page fault-> LRU -> replaces page 2 by page 3

121030424

0 3 1 4 2

5. Page 0 is referenced-> page hit

121030424

0 3 1
6. Page 4 is referenced -> not in memory->page fault-> LRU -> replace page 1 by page 4

121030424

0 3 4 6 2

7. Page 2 is referenced-> not in memory-> page fault ->LRU -> replace page 3 by page 2

121030424

0 2 4
8. Page 4 is referenced-> page hit

121030424

0 2 4 6 3
Algorithm
s = main memory capacity
STEP 1
Iterate through the referenced pages.
If the current page is already present in the pages:
1. Remove the current page from pages.
2. Append current page to end of pages.
3. Increment page hits.

Else:
1. Increment page faults.
2. If page contains less pages than capacity s:
# Append current page to pages.
Else:
# Remove first page from pages
# Append current page to end of pages

STEP 2
Return number of page hits and page faults
Advantages
The page that has not been used for a
long time gets replaced
Gives less page faults
Capable of complete analysis

Disadvantages
Execution is complicated
Algorithm may need significant
assistance from hardware.
Thank You

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy