200 likes | 318 Views
Stuff iThink that will be on the Quiz/Midterm. Page Replacement. by Andrew Yee. What is Page Replacement?. Virtual Memory Memory Management. Why Page Replacement?. Cache is limited. Need ways to manage virtual memory in Cache. How to Page Replace?.
E N D
Stuff iThinkthat will be on the Quiz/Midterm. Page Replacement by Andrew Yee
What is Page Replacement? Virtual Memory Memory Management
Why Page Replacement? • Cache is limited • Need ways to manage virtual memory in Cache
How to Page Replace? • Cache is limited small, you have to figure out ways to choose which pages to keep in cache. Which you think would most likely be used again in the future . • FIFO and LRU are techniques used to determine which pages should be kept cache. • Optimal is the best possible outcome because you use future knowledge which pages will be used again to determine which pages to keep. • 3 Ways to manage Virtual Memory in Cache • Optimal – Best possible outcome • LRU - Least Recently Used • FIFO - First In First Out Think “Stacks”
How to Represent Pages in Time? Time increases Frame set that can 3 page reference string. Frame cell that can hold a page reference string. CPU issues the page reference string. Think Animated “Stacks”
How to Represent Page Hit and Page Fault (miss)? Time increases Page Hit – Don’t box the frame set Page Fault (miss) – box the frame set Think Animated “Stacks”
Optimal Method • What you need? Requires Future Knowledge.
Example of Optimal Method 1 2 1 3 2 1 4 2 1 4 2 1 4 2 1 4 2 1 4 2 1 4 2 1 4 5 1 4 5 1 4 5 1 4 5 1 4 5 1 5 –Page Fault (Missed) Each of the rectangle is a frame, and each number is a page. Page fault (miss) is when you cant find the page in cache. A hit is when you do find it. You want to minimize the # of miss. Each cell contains a Page.
FIFO – First in First Out Method • How? First Page In First Page Out
Example of FIFO Method 1 2 1 3 2 1 4 3 2 4 3 2 1 4 3 2 1 4 2 1 4 2 1 4 5 2 1 4 5 2 4 5 2 1 4 5 1 4 5 9 –Page Fault (Missed) Each of the rectangle is a frame, and each number is a page. Page fault (miss) is when you cant find the page in cache. A hit is when you do find it. You want to minimize the # of miss. Each cell contains a Page.
LRU – Least Recently Used • Key to this method is: Past experience may indicate future behavior
Example of LRU Method 1 2 1 3 2 1 4 3 2 4 3 2 1 4 3 2 1 4 1 2 4 4 1 2 5 4 1 4 5 1 5 4 1 1 5 4 4 1 5 7 –Page Fault (Missed) Each of the rectangle is a frame, and each number is a page. Page fault (miss) is when you cant find the page in cache. A hit is when you do find it. You want to minimize the # of miss. Each cell contains a Page.
Hit Ratio • Hit Ratio = (Total # of Frame Set - # of Page Fault) ---------------------------------------------------- * 100 Total # of Frame Set
Practice Example • Compute the hit ratio of each method: • Optimal, FIFO, LRU
Practice Example • Compute the hit ratio of each method: • Optimal 1 3 1 3 6 3 1 4 6 3 Number of Page Fault = 4 Hit ratio = (5 - 4) / 5 * 100 = 20%
Practice Example • Compute the hit ratio of each method: • FIFO 1 3 1 3 1 6 3 1 4 6 3 Number of Page Fault = 4 Hit ratio = (5 - 4) / 5 * 100 = 20%
Practice Example • Compute the hit ratio of each method: • LRU 1 3 1 3 1 6 3 1 4 6 3 Number of Page Fault = 4 Hit ratio = (5 - 4) / 5 * 100 = 20%