0% found this document useful (0 votes)
810 views22 pages

LRU Example (3 Frames)

This document demonstrates the Least Recently Used (LRU) page replacement algorithm using a reference string of page requests and 3 frames of RAM. It shows the contents of RAM frames after each page request and tracks which page is replaced. In total there were 12 page faults, with 9 faults after loading the first 3 pages. It then compares the performance of LRU to FIFO and OPT algorithms on this example reference string.

Uploaded by

Vu Hoa
Copyright
© Attribution Non-Commercial (BY-NC)
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)
810 views22 pages

LRU Example (3 Frames)

This document demonstrates the Least Recently Used (LRU) page replacement algorithm using a reference string of page requests and 3 frames of RAM. It shows the contents of RAM frames after each page request and tracks which page is replaced. In total there were 12 page faults, with 9 faults after loading the first 3 pages. It then compares the performance of LRU to FIFO and OPT algorithms on this example reference string.

Uploaded by

Vu Hoa
Copyright
© Attribution Non-Commercial (BY-NC)
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

LRU Example (3 frames)

Reference String

7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
Frames of RAM
LRU Example (3 frames)
*
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

7
LRU Example (3 frames)
* *
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

7 7

0
LRU Example (3 frames)
* * *
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

7 7 7

0 0

1
LRU Example (3 frames)
* * * *
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

7 7 7 2

0 0 0

1 1

Page 7 has not been used for the longest period of


time, so replace it
LRU Example (3 frames)
* * * *
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

0 0 0 0

1 1 1
LRU Example (3 frames)
* * * * *
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 2

0 0 0 0 0

1 1 1 3
LRU Example (3 frames)
* * * * *
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 2 2

0 0 0 0 0 0

1 1 1 3 3
LRU Example (3 frames)
* * * * * *
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 2 2 4

0 0 0 0 0 0 0

1 1 1 3 3 3
LRU Example (3 frames)
* * * * * * *
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 2 2 4 4

0 0 0 0 0 0 0 0

1 1 1 3 3 3 2
LRU Example (3 frames)
* * * * * * * *
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 2 2 4 4 4

0 0 0 0 0 0 0 0 3

1 1 1 3 3 3 2 2
LRU Example (3 frames)
* * * * * * * * *
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 2 2 4 4 4 0

0 0 0 0 0 0 0 0 3 3

1 1 1 3 3 3 2 2 2
LRU Example (3 frames)
* * * * * * * * *
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 2 2 4 4 4 0 0

0 0 0 0 0 0 0 0 3 3 3

1 1 1 3 3 3 2 2 2 2
LRU Example (3 frames)
* * * * * * * * *
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 2 2 4 4 4 0 0 0

0 0 0 0 0 0 0 0 3 3 3 3

1 1 1 3 3 3 2 2 2 2 2
LRU Example (3 frames)
* * * * * * * * * *
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 2 2 4 4 4 0 0 0 1

0 0 0 0 0 0 0 0 3 3 3 3 3

1 1 1 3 3 3 2 2 2 2 2 2
LRU Example (3 frames)
* * * * * * * * * *
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 2 2 4 4 4 0 0 0 1 1

0 0 0 0 0 0 0 0 3 3 3 3 3 3

1 1 1 3 3 3 2 2 2 2 2 2 2
LRU Example (3 frames)
* * * * * * * * * * *
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 2 2 4 4 4 0 0 0 1 1 1

0 0 0 0 0 0 0 0 3 3 3 3 3 3 0

1 1 1 3 3 3 2 2 2 2 2 2 2 2
LRU Example (3 frames)
* * * * * * * * * * *
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 2 2 4 4 4 0 0 0 1 1 1 1

0 0 0 0 0 0 0 0 3 3 3 3 3 3 0 0

1 1 1 3 3 3 2 2 2 2 2 2 2 2 2
LRU Example (3 frames)
* * * * * * * * * * * *
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 2 2 4 4 4 0 0 0 1 1 1 1 1

0 0 0 0 0 0 0 0 3 3 3 3 3 3 0 0 0

1 1 1 3 3 3 2 2 2 2 2 2 2 2 2 7
LRU Example (3 frames)
* * * * * * * * * * * *
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 2 2 4 4 4 0 0 0 1 1 1 1 1 1

0 0 0 0 0 0 0 0 3 3 3 3 3 3 0 0 0 0

1 1 1 3 3 3 2 2 2 2 2 2 2 2 2 7 7
LRU Example (3 frames)
* * * * * * * * * * * *
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 2 2 4 4 4 0 0 0 1 1 1 1 1 1 1

0 0 0 0 0 0 0 0 3 3 3 3 3 3 0 0 0 0 0

1 1 1 3 3 3 2 2 2 2 2 2 2 2 2 7 7 7

So, 12 page faults for this reference string, LRU, & 3 frames
Comparison (On Example)
Page Number of Number of
replacement faults faults (not
algorithm (including including
first three) first three)
FIFO 15 12

OPT 9 6

LRU 12 9

You might also like