Page Replacement.

Slides:



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

Chapter 4 Memory Management Basic memory management Swapping
Chapter 3 Memory Management
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Memory Management.
Paging: Design Issues. Readings r Silbershatz et al: ,
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
Chapter 9: Virtual Memory
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Virtual Memory Operating System Concepts chapter 9 CS 355
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
Module 10: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing.
Virtual Memory Introduction to Operating Systems: Module 9.
Memory Management Design & Implementation Segmentation Chapter 4.
Operating System Support Focus on Architecture
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Memory Management 2010.
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.
Virtual Memory Chapter 8.
Computer Organization and Architecture
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
Virtual Memory Management B.Ramamurthy. Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Maninder Kaur VIRTUAL MEMORY 24-Nov
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Virtual Memory.
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Memory Management Page replacement algorithms, segmentation Tanenbaum, ch. 3 p Silberschatz, ch. 8, 9 p
Memory Management From Chapter 4, Modern Operating Systems, Andrew S. Tanenbaum.
Memory Management 3 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
1 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms.
Chapter 4 Memory Management Virtual Memory.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
Virtual Memory. Background Virtual memory is a technique that allows execution of processes that may not be completely in the physical memory. Virtual.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Demand Paging Reference Reference on UNIX memory management
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
操作系统原理 OPERATING SYSTEM Chapter 3 Memory Management 内存管理.
Page Replacement Implementation Issues Text: –Tanenbaum ch. 4.7.
1 Lecture 8: Virtual Memory Operating System Fall 2006.
1 Memory Management Chapter Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
1 Memory Management Adapted From Modern Operating Systems, Andrew S. Tanenbaum.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Virtual Memory What if program is bigger than available memory?
Memory Management Chapter 3
MODERN OPERATING SYSTEMS Third Edition ANDREW S
SLC/VER1.0/OS CONCEPTS/OCT'99
Logistics Homework 5 will be out this evening, due 3:09pm 4/14
Session 3 Memory Management
Chapter 9: Virtual Memory – Part I
Chapter 9: Virtual Memory
Module 9: Virtual Memory
Chapter 9: Virtual-Memory Management
5: Virtual Memory Background Demand Paging
Chapter 9: Virtual Memory
Chapter 4: Memory Management
Contents Memory types & memory hierarchy Virtual memory (VM)
CSE 542: Operating Systems
Module 9: Virtual Memory
COMP755 Advanced Operating Systems
Virtual Memory.
CSE 542: Operating Systems
Module IV Memory Organization.
Presentation transcript:

Page Replacement

Section 3.4 Caching and Paging Algorithms

Virtual Memory Caches, page files Exist on disk to enlarge RAM A cache of information stored for faster access Virtual memory exists to extend main memory

What are these algorithms? Optimize virtual memory or cache management Examples are random replacement, least frequently used, and most-recently used Each algorithm is better for some applications; there is no default

Design Goals To achieve the lowest page fault rate (situations where a page must be brought in from disk) Each algorithm is evaluated differently based on the application Swap the page that will be least used in the future*

Pages in Virtual Memory The virtual memory has it’s own address space Divided into pages, which hold virtual addresses When a page is needed, it’s copied to main memory and allocated address spaces – paging Hence the name - pagefile

Page Faults Occurs when a program requests data that is not currently in RAM. The O/S must then fetch the data from a page file and load it into RAM. Not actually an error, necessary for many programs to run

Page Replacement What happens if there is no free frame to allocate? Find some frame in memory which “isn’t that used”* and swap it out RAM V.M.

Least Recently Used (LRU) Pages that were heavily used in the last few instructions will probably be heavily used in the next few Throw out the page that has been unused for the longest time Maintain a linked list of all pages in memory, with the most recently used page at the front - not cheap

Conclusion The perfect algorithm; easy to describe, impossible to implement Page faults are inevitable and sometimes necessary Algorithms can be designed many ways to account for individual platforms

Design Issues for Paging Systems Section 3.5 Design Issues for Paging Systems by Steven Palmer

Issues to be Covered Local Vs Global Allocation Load Control Page Size Separate Instruction & Data Spaces Shared Pages & Libraries Mapped Files Cleaning Policy Virtual Memory Interface

Local Vs Global Allocation Global is better overall Page Fault Frequency algorithm

Load Control Beware of Thrashing PFF as warning sign Swapping processes in & out of memory

Page Size & Separate Instruction & Data Spaces se/2 + p/2 =0 yields p = sqrt(2se) Increasing available space

Shared Pages, Libraries, & Mapped Files Sharing : Is Conducive to multiprogramming Is scalable reduces repetition easy to update Has problems multiprogrammin g libraries Enables communication

Cleaning Policy & VM Interface The Paging Daemon is your friend inspects cleans Virtual Memory Interface Enabling sharing Allows high-performance messaging b/t processes or across networks Distributed shared memory

Issues Covered Local Vs Global Allocation Load Control Page Size Separate Instruction & Data Spaces Shared Pages & Libraries Mapped Files Cleaning Policy Virtual Memory Interface

Conclusion Memory management Design matters Sharing is caring

Questions on anything covered?

Section 3.6Implementation Issues for paging Systems

Issues to be Discussed - OS Involvement - Page Fault Handling - Instruction - Locking Pages in Memory - Backing Store - Separation of Policy and Mechanism

OS Involvement - Process Creation Time - Process Execution Time - Create page table - Allocation of space in swap area - Process Execution Time - MMU must be reset and TLB flushed - New page table must be made current - Page Fault Time - Read hardware registers - Perform page replacement - Process Termination Time - Release page table, pages and disk space MMU = Memory management unit TLB = Translation lookaside buffer

Page Fault Handling Sequence to Page Fault Handling 1 - Hardware traps to kernel 2 - Assembly code routine started 3 - OS discovers page fault and its address 4 - OS checks address 5 - Page scheduled for transfer 6 - OS looks up address for needed page 7 - Page tables updated 8 - Faulting instruction and program counter reset 9 - Faulting process scheduled 10 - Routine returns to user space to continue execution

Figure 3-28 an instruction causing a page fault. Instruction Backup - When page fault is resolved, instructions must be restarted. - Easier said than done - Some CPUs provide solution Figure 3-28 an instruction causing a page fault.

Locking Pages in Memory - Some pages in memory should not be removed. - “Pinning” a page to memory - Another solution is Kernel Buffers

- Fixed Swapping Partition - Program size is not fixed Backing Store - Fixed Swapping Partition - Program size is not fixed - Not always logistically possible - Dynamic Swapping Partition - Additional table per process

Backing Store Figure 3-29 (a) Paging to a static swap area. (b) Backing up pages dynamically.

Separation of Policy and Mechanism - Memory manager run user-level. - No access to R and M bits - Advantages: Modular Code and Flexibility - Disadvantages: Multiple User-Kernel boundary crossings, extra overhead.

Separation of Policy and Mechanism Figure 3-30 Page fault handling with an external pager.

Conclusion

Questions?