Presentation is loading. Please wait.

Presentation is loading. Please wait.

By Andrew Yee. Virtual Memory Memory Management What is Page Replacement?

Similar presentations


Presentation on theme: "By Andrew Yee. Virtual Memory Memory Management What is Page Replacement?"— Presentation transcript:

1 by Andrew Yee

2 Virtual Memory Memory Management What is Page Replacement?

3 Why Page Replacement? Cache is limited Need ways to manage virtual memory in Cache

4 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. How to Page Replace? 3 Ways to manage Virtual Memory in Cache 1.Optimal – Best possible outcome 2.LRU - Least Recently Used 3.FIFO - First In First Out Think “Stacks”

5 How to Represent Pages in Time? Think Animated “Stacks” 123 Time increases CPU issues the page reference string. Frame cell that can hold a page reference string. Frame set that can 3 page reference string.

6 How to Represent Page Hit and Page Fault (miss)? Think Animated “Stacks” 1234 Time increases Page Fault (miss) – box the frame set Page Hit – Don’t box the frame set

7 Optimal Method What you need? Requires Future Knowledge.

8 Example of Optimal Method 12344121454514 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. 12 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)

9 FIFO – First in First Out Method How? First Page In First Page Out

10 Example of FIFO Method 12344121454514 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. 12 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)

11 LRU – Least Recently Used Key to this method is: Past experience may indicate future behavior

12 Example of LRU Method 12344121454514 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. 12 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)

13 Page Fault Comparison Methods# of Page Fault Optimal 5 FIFO – First In First Out 9 LRU – Least Recently Used 7

14 Practical Method Comparison Methods# of Page FaultWhat we Need? Optimal 5 Future Knowledge FIFO – First In First Out 9 1 st page LRU – Least Recently Used 7 Past Experience

15 Hit Ratio Hit Ratio = (Total # of Frame Set - # of Page Fault) ---------------------------------------------------- * 100 Total # of Frame Set

16 Hit Ratio Methods# of Page FaultTotal # of Frame SetHit Ratio Optimal 5 14 (14-5)/14* 100 = 9/14 *100 = 64.29% FIFO – First In First Out 9 1435.71% LRU – Least Recently Used 7 1450%

17 Practice Example Compute the hit ratio of each method: – Optimal, FIFO, LRU 13364

18 Practice Example Compute the hit ratio of each method: – Optimal 13364 1 13 1 36 3 1 4 6 3 Number of Page Fault = 4 Hit ratio = (5 - 4) / 5 * 100 = 20%

19 Practice Example Compute the hit ratio of each method: – FIFO 13364 13 1 3 1 6 3 1 4 6 3 Number of Page Fault = 4 Hit ratio = (5 - 4) / 5 * 100 = 20%

20 Practice Example Compute the hit ratio of each method: – LRU 13364 13 1 3 1 6 3 1 4 6 3 Number of Page Fault = 4 Hit ratio = (5 - 4) / 5 * 100 = 20%


Download ppt "By Andrew Yee. Virtual Memory Memory Management What is Page Replacement?"

Similar presentations


Ads by Google