CS 241 Spring 2007 System Programming 1 Memory Replacement Policies Lecture 32 Klara Nahrstedt.

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Advertisements

SE-292 High Performance Computing
Chapter 4 Memory Management Basic memory management Swapping
CS Introduction to Operating Systems
9.4 Page Replacement What if there is no free frame?
Page Replacement Algorithms
Page Replacement Algorithms
Virtual Memory (Chapter 4.3)
Virtual Memory Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution -
Cache and Virtual Memory Replacement Algorithms
Chapter 101 The LRU Policy Replaces the page that has not been referenced for the longest time in the past By the principle of locality, this would be.
Chapter 3.3 : OS Policies for Virtual Memory
Chapter 11 – Virtual Memory Management
Virtual Memory 3 Fred Kuhns
Module 10: Virtual Memory
Chapter 3 Memory Management
Chapter 10: Virtual Memory
Chapter 11 – Virtual Memory Management
Page Replacement Algorithms (Virtual Memory)
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Chapter 9: Virtual Memory
Virtual Memory II Chapter 8.
Memory Management.
Scribe for 7 th April 2014 Page Replacement Algorithms Payal Priyadarshini 11CS30023.
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
SE-292 High Performance Computing Memory Hierarchy R. Govindarajan
Virtual Memory Management G. Anuradha Ref:- Galvin.
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Module 9: Virtual Memory
Module 10: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing.
Virtual Memory Background Demand Paging Performance of Demand Paging
Virtual Memory Introduction to Operating Systems: Module 9.
Day 23 Virtual Memory. Operating system’s role in VM Hardware-support Use VM or not Use paging or segmentation or both Software domain Algorithms for.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Virtual Memory.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management – 4 Page Replacement Algorithms CS 342 – Operating Systems.
Paging Algorithms Vivek Pai / Kai Li Princeton University.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
1 Lecture 9: Virtual Memory Operating System I Spring 2007.
Memory Management Virtual Memory Page replacement algorithms
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Revisiting Virtual Memory.
CSI 400/500 Operating Systems Spring 2009 Lecture #9 – Paging and Segmentation in Virtual Memory Monday, March 2 nd and Wednesday, March 4 th, 2009.
CS444/CS544 Operating Systems Virtual Memory 4/06/2007 Prof. Searleman
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
03/29/2004CSCI 315 Operating Systems Design1 Page Replacement Algorithms (Virtual Memory)
O RERATıNG S YSTEM LESSON 10 MEMORY MANAGEMENT II 1.
Page 19/17/2015 CSE 30341: Operating Systems Principles Optimal Algorithm  Replace page that will not be used for longest period of time  Used for measuring.
Operating Systems CMPSC 473 Virtual Memory Management (3) November – Lecture 20 Instructor: Bhuvan Urgaonkar.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
CS307 Operating Systems Virtual Memory Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
Virtual Memory The address used by a programmer will be called a virtual address or logical address. An address in main memory is called a physical address.
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 9: Virtual-Memory Management 9.1 Background.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
Virtual Memory. 2 Last Week Memory Management Increase degree of multiprogramming –Entire process needs to fit into memory Dynamic Linking and Loading.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Day 22 Virtual Memory.
Lecture 10: Virtual Memory
Review.
Module 9: Virtual Memory
Chapter 9: Virtual Memory
Chapter 9: Virtual-Memory Management
Lecture 39 Syed Mansoor Sarwar
5: Virtual Memory Background Demand Paging
Operating Systems CMPSC 473
Module 9: Virtual Memory
Virtual Memory.
Presentation transcript:

CS 241 Spring 2007 System Programming 1 Memory Replacement Policies Lecture 32 Klara Nahrstedt

2 CS241 Administrative Read Stallings Chapter 8.1 and 8.2 about VM LMP2 (Part II due on Monday, April 16) See also lecture notes, self-assessment quiz, discussion section LMP2 quiz on Monday, April 16 If you found Dr. Cerfs lecture interesting, you can Pay attention next two weeks in cs241 were we cover socket interfaces to TCP/IP - Internet Learn more about Internet material in classes cs438 (Communication Networking – TCP/IP), cs425 (Distributed Systems), ece435 (Computer Networking Lab – Implementation of TCP/IP), cs414 (Multimedia Systems), cs463 (Computer Security

3 Concepts this Lecture Introduction to Demand Paging Replacement Principle of Optimality Replacement Policies

4 Introduction to Demand Paging - Paging Policies Fetch Strategies When should a page be brought into primary (main) memory from secondary (disk) storage. Placement Strategies When a page is brought into primary storage, where is it to be put? Replacement Strategies Which page now in primary storage is to be removed from primary storage when some other page or segment is to be brought in and there is not enough room.

5 Demand Paging Example Load M i Free frame Page table VM ref fault

6 Page Replacement Algorithm find a free page frame if free page frame use it otherwise, select a page frame using the page replacement algorithm write the selected page to the disk and update any necessary tables find location of page on disk read the requested page from the disk. restart the user process.

7 Page Replacement It is necessary to be careful of synchronization problems. For example, page faults may occur for pages being paged out.

8 Page Replacement Issues if no frames are free, a disk read and write of page is required if the page to be replaced has not been changed since it was read in, it can be discarded and does not need to be copied out to secondary storage. read only pages are never written but may be shared!

9 Page Replacement Issues a dirty bit is set in the page table by hardware to indicate that the page has been modified. need to minimize page faults. reference string is the memory references generated by a program.

10 Page Replacement Strategies the principle of optimality replace the page that will not be used again the farthest time in the future. random page replacement choose a page randomly FIFO - first in first out replace the page that has been in primary memory the longest

11 Terminology Reference string: the memory reference sequence generated by a program. Paging – moving pages to (from) disk Optimal – the best (theoretical) strategy Eviction – throwing something out Pollution – bringing in useless pages/lines

12 Page Replacement Strategies LRU - least recently used replace the page not used for the longest time LFU - least frequently used replace the page that is used least often NUR - not used recently an approximation to LRU. working set keep in memory those pages that the process is actively using.

13 Principal of Optimality provides a basis for comparison with other schemes. is difficult to implement because of trying to predict the reference string for a program. compiler technology can help by providing hints.

14 Principal of Optimality if the reference string can be predicted accurately, then shouldn't use demand paging but should use pre-paging instead as this would allow paging activity of pages needed in the future to be overlapped with computation.

15 Optimal Example 12 references, 7 faults

16 FIFO 12 references, 9 faults

17 Paging Behavior with Increasing Number of Page Frames

18 Belady's Anomaly (for FIFO) As the number of page frames increase, so does the fault rate. 12 references, 10 faults

19 LRU 12 references, 10 faults

20 Least Recently Used Issues does not suffer from Belady's anomaly use time record time of reference with page table entry use counter as clock search for smallest time. use stack remove reference of page from stack (linked list) push it on top of stack both approaches require large processing overhead, more space, and hardware support.

21 LRU and Anomalies Anomalies cannot occur, why? 12 references, 8 faults

22 NUR: A LRU Approximation additional reference bits a register is kept per page a one bit is set in the register if the page is referenced the register is shifted by one after some time interval would be accessed more recently than the page with register holding the lowest number is the least recently used. the value may not be unique. use fifo to resolve conflicts.

23 Second Chance second chance algorithm uses a register size one: a reference bit. the page table entry has a reference bit initially, the reference bit for a page is set to 0 when a page is referenced, the page is set to 1 pages are kept in FIFO order using a circular list. select head of FIFO

24 Second Chance if page has reference bit set, reset bit and select next page in FIFO list. keep processing until reach page with zero reference bit and page that one out. system v, r4 uses a variant of second chance.

25 Second Chance Example 12 references, 9 faults

26 Page Classes 1.(0,0) neither referenced nor dirtied 2.(0,1) not referenced (recently) but dirtied 3.(1,0) referenced but clean 4.(1,1) referenced and dirtied select a page from lowest class if conflict, use random or FIFO.

27 Summary Fetch, placement, page replacement. Demand paging algorithm. Simple page replacement policies. Optimal FIFO LRU NUR Second chance, page classes