Virtual Memory (II) CSCI 444/544 Operating Systems Fall 2008.

Slides:



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

Virtual Memory (Chapter 4.3)
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Virtual Memory: Page Replacement
Paging: Design Issues. Readings r Silbershatz et al: ,
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 36 Virtual Memory Read.
Virtual Memory.
Operating Systems Prof. Navneet Goyal Department of Computer Science & Information Systems BITS, Pilani.
Chapter 101 Cleaning Policy When should a modified page be written out to disk?  Demand cleaning write page out only when its frame has been selected.
Module 9: Virtual Memory
Module 10: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing.
1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.
Virtual Memory Background Demand Paging Performance of Demand Paging
Virtual Memory Introduction to Operating Systems: Module 9.
Segmentation and Paging Considerations
CS 153 Design of Operating Systems Spring 2015 Lecture 19: Page Replacement and Memory War.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Memory Management Design & Implementation Segmentation Chapter 4.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
1 Virtual Memory in the Real World Implementing exact LRU Approximating LRU Hardware Support Clock Algorithm Thrashing Cause Working Set.
1 Virtual Memory vs. Physical Memory So far, all of a job’s virtual address space must be in physical memory However, many parts of programs are never.
Memory Management 2010.
Virtual Memory CSCI 444/544 Operating Systems Fall 2008.
OS Spring’04 Virtual Memory: Page Replacement Operating Systems Spring 2004.
CSCI2413 Lecture 6 Operating Systems Memory Management 2 phones off (please)
03/29/2004CSCI 315 Operating Systems Design1 Page Replacement Algorithms (Virtual Memory)
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
VIRTUAL MEMORY By Thi Nguyen. Motivation  In early time, the main memory was not large enough to store and execute complex program as higher level languages.
Copyright ©: Lawrence Angrave, Vikram Adve, Caccamo 1 Virtual Memory.
Virtual Memory Virtual Memory is created to solve difficult memory management problems Data fragmentation in physical memory: Reuses blocks of memory.
Virtual Memory. Background Virtual memory is a technique that allows execution of processes that may not be completely in the physical memory. Virtual.
Lecture 11 Page 1 CS 111 Online Working Sets Give each running process an allocation of page frames matched to its needs How do we know what its needs.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
CS 3204 Operating Systems Godmar Back Lecture 21.
Virtual Memory Questions answered in this lecture: How to run process when not enough physical memory? When should a page be moved from disk to memory?
CSE 153 Design of Operating Systems Winter 2015 Lecture 12: Page Replacement.
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
Virtual Memory. 2 Last Week Memory Management Increase degree of multiprogramming –Entire process needs to fit into memory Dynamic Linking and Loading.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
SLC/VER1.0/OS CONCEPTS/OCT'99
Logistics Homework 5 will be out this evening, due 3:09pm 4/14
Virtual memory.
CS703 - Advanced Operating Systems
CSE 120 Principles of Operating
Module 9: Virtual Memory
Lecture 28: Virtual Memory-Address Translation
Chapter 9: Virtual-Memory Management
Lecture 27: Virtual Memory
Page Replacement.
5: Virtual Memory Background Demand Paging
Main Memory Background Swapping Contiguous Allocation Paging
Demand Paged Virtual Memory
Operating Systems.
Chapter 4: Memory Management
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Operating Systems CMPSC 473
Virtual Memory: Working Sets
CSE 153 Design of Operating Systems Winter 19
Module 9: Virtual Memory
Virtual Memory.
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

Virtual Memory (II) CSCI 444/544 Operating Systems Fall 2008

Agenda Memory allocation across multiple processes Thrashing Working set Trends

Memory Allocation Across Processes Physical pages allocated to several processes A, B, and C. –Process B page faults. Which page should be replaced? Three options –Per-process replacement –Per-user replacement –Global replacement

Per-process Replacement Each process has separate pool of pages –Fixed number of pages (e.g., Digital VMS) –Fixed fraction of physical memory (1/P) –Proportional to size of allocated address space Page fault in one process only replaces pages of that process –Perform replacement (e.g., LRU) over only those pages Advantage: No interference across processes Disadvantage: Potentially inefficient allocation of memory

Per-user Replacement Each user has separate pool of pages Advantage: Fair across different users Disadvantage: Inefficient allocation as well

Global Replacement Pages from all processes lumped into single replacement pool –Example: Run clock over all page frames Each process competes with other processes for frames Advantages: –Flexibility of allocation –Minimize total number of page faults Disadvantages –One memory-intensive process can hog memory, hurt all processes

Impact of Additional Processes What happens to performance as add more processes? Consider CPU utilization as metric Increase number of processes from 1 –Process blocks: Other processes can run –CPU utilization increases with more processes Increase number of processes after memory filled –Increases number of page faults –Memory contention increases with more processes –CPU utilization decreases with more processes

Thrashing when the system spends most of its time servicing page faults, little time doing useful work Implication: Average memory access time = disk access time Memory appears as slow as disk, instead of disk appearing as fast as memory could be that there is enough memory but a lousy replacement algorithm (one incompatible with program behavior) could be that memory is over-committed –too many active processes

Thrashing (II)

Solution to Thrashing Thrashing cannot be fixed with better replacement policies only Page replacement policies do not indicate that a page must be kept in memory Only show which pages are better than others to replace Students analogy to thrashing: Too many courses Solution: Drop a course OS solution: Admission control Determine how much memory each process needs Long-term scheduling policy

Working Set Informal definition Collection of pages the process is referencing frequently Collection of pages that must be resident to avoid thrashing Implication Locality exists Working set changes slowly over time Example: Page reference stream: A B A B C B A C A C D C D E B E D F B F D B E D

Working Set Model of Program Behavior The working set of a process is used to model the dynamic locality of its memory usage working set = set of pages process currently needs formally defined by Peter Denning in the 1960s Formal Definition: WS(t,w) = {pages P such that P was referenced in the time interval (t, t-w)} –t: time –w: working set window (measured in page refs) –a page is in the working set (WS) only if it was referenced in the last w references obviously the working set (the particular pages) varies over the life of the program so does the working set size (the number of pages in the WS)

Working Set Size The working set size, |WS(t,w)|, changes with program locality during periods of poor locality, more pages are referenced within that period of time, the working set size is larger Intuitively, the working set must be in memory, otherwise youll experience heavy faulting (thrashing) when people ask How much memory does Firefox need?, really theyre asking what is Firefoxs average (or worst case) working set size?

Balance Set Motivation: Process should not be scheduled unless working set is resident in main memory Divide runnable processes into two groups: Active: Working set is loaded Inactive: Working set is swapped to disk Balance set: Sum of working sets of all active processes Interaction with scheduler If balance set exceeds size of memory, move some process to inactive set If balance set is less than size of memory, move some process to active set

Trends VM code is not as critical as before Reason #1: Personal vs. time-shared machine Reason #2: Memory is more affordable, more memory Less hardware support for replacement policies Software emulation of reference and dirty bits Larger page sizes Better TLB coverage Smaller page tables Disadvantage: More internal fragmentation –Multiple page sizes