Implementation of LRU

Implementation of LRU - Chance Algorithm) 1 2 3 Page 4 5 1...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Implementation of LRU To implement LRU we would need to have a timestamp in each page to know when was the last time page was accessed. This timestamp is approximated using the accessed and modified bits.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Clock Algorithm (Second Chance Algorithm) Initially all the access bits are clear. All RAM pages are in a list. If a page needs to be replaced, start the search one page after the last page replaced (one after where the last search ended) If the page has the access bit set, clear the bit and skip that page. If the page has the bit not set, use that page for replacement. When the end of the list is reached start from the top. In this algorithm, pages accessed since the last time
Background image of page 2
Clock Algorithm (Second Chance Algorithm) 1 2 3 Page 4 5 1 1 0 1 0 Access Bit Start 0 0 0 1 0 Foun d Access Bit
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Clock Algorithm (Second Chance Algorithm) 1 2 3 Page 4 5 0 0 1 1 0 Access Bit Start 0 0 1 0 0 Foun d Access Bit
Background image of page 4
Clock Algorithm (Second
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chance Algorithm) 1 2 3 Page 4 5 1 1 1 1 Access Bit Start 1 1 1 Foun d Access Bit Assume page 1 is accessed so it will be skipped. Improved Clock Algorithm In the simple second chance if a referenced page gets another chance. The access bit goes from 1 -> 0->Replacement . An improved second chance Also uses the modified bit. Access Modified 0 0 Best candidate 0 chances 0 1 Not as bad candidate 2 chances 1 0 Better Candidate 1 chances 1 1 Worst Candidate 3 chances Improved Clock Algorithm When visiting a page the access and modified bits are changed in this way correspondingly: 11 -> 01 -> 10-> 00->Replacement . Modified bits are saved into OS data structures before updating In this way a page that has been accessed and modified will get three chances before it is being replaced....
View Full Document

This note was uploaded on 01/30/2012 for the course CS 354 taught by Professor Staff during the Fall '08 term at Purdue.

Page1 / 7

Implementation of LRU - Chance Algorithm) 1 2 3 Page 4 5 1...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online