Virtual Memory Virtual Memory is created to solve difficult memory management problems Data fragmentation in physical memory: Reuses blocks of memory.

Slides:



Advertisements
Similar presentations
Chapter 11 – Virtual Memory Management
Advertisements

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 8 Virtual Memory
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
Part IV: Memory Management
Memory Management Chapter 7.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
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.
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)
Virtual Memory Chapter 8.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Lecture 11: Memory Management
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
CS 104 Introduction to Computer Science and Graphics Problems
Memory Management 2010.
Chapter 11 – Virtual Memory Management Outline 11.1 Introduction 11.2Locality 11.3Demand Paging 11.4Anticipatory Paging 11.5Page Replacement 11.6Page Replacement.
Virtual Memory Chapter 8.
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main 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.
Computer Organization and Architecture
Virtual Memory Deung young, Moon ELEC 5200/6200 Computer Architecture and Design Lectured by Dr. V. Agrawal Lectured by Dr. V.
CSCI2413 Lecture 6 Operating Systems Memory Management 2 phones off (please)
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.
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.
CS212: OPERATING SYSTEM Lecture 6: Virtual-Memory Management 1 Computer Science Department.
Subject: Operating System.
Page Replacement Algorithms Memory Management. Optimal Page Replacement ▪The label for each page in memory is labeled with the number of instructions.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Computer Systems Week 14: Memory Management Amanda Oddie.
CS 241 Section Week #9 (11/05/09). Topics MP6 Overview Memory Management Virtual Memory Page Tables.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
Memory Management. Why memory management? n Processes need to be loaded in memory to execute n Multiprogramming n The task of subdividing the user area.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
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.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
CE 454 Computer Architecture
Chapter 2 Memory and process management
ITEC 202 Operating Systems
Chapter 9 – Real Memory Organization and Management
Day 20 Virtual Memory.
Chapter 8 Virtual Memory
Virtual Memory Chapter 8.
Lecture 10: Virtual Memory
Chapter 9: Virtual Memory
O.S Lecture 13 Virtual Memory.
Chapter 9: Virtual-Memory Management
Page Replacement.
What Happens if There is no Free Frame?
Chapter 9: Virtual Memory
Contents Memory types & memory hierarchy Virtual memory (VM)
Computer Architecture
Operating Systems Concepts
COMP755 Advanced Operating Systems
Operating Systems: Internals and Design Principles, 6/E
Virtual Memory.
Chapter 8 & 9 Main Memory and Virtual Memory
CSE 542: Operating Systems
Presentation transcript:

Virtual Memory Virtual Memory is created to solve difficult memory management problems Data fragmentation in physical memory: Reuses blocks of memory that would otherwise be unused when programs free up data. Physical memory size constraints are also solved by using alternate forms of data storage to act like memory. Implemented via Paging or Segmentation Problem: Thrashing reduces preformance

Virtual Memory Overview Techniques used to give an application program logical access to contiguous working memory In reality the data is fragmented in primary and secondary memory.

Virtual Memory Memory Fragmentation Not just using disk space to extend the physical memory. Uses real physical memory more efficiently. Tricks programs into thinking they are using large blocks of contiguous addresses. Reuses fragments in memory.

Virtual Memory: A History 1950s: Primary memory Magnetic Core Memory (non-volatile)‏

Drum Memory (non-volatile)‏ Virtual Memory: A History 1950s: Secondary memory Drum Memory (non-volatile)‏ (BSD Unix: /dev/drum is default name for swap)‏

Virtual Memory Overlays Before virtual memory, programs that were too big for the size of physical memory used Overlays Overlays still popular in embedded systems that require cheap hardware Overlays require the programmer to manage memory for each program.

Virtual Memory Overlays Program manually divided into self-contained code blocks called Overlays Size of Overlay limited by memory constraints (different for different systems)‏ Programmer had to use specific programming languages or assembly language to have control over the size of the program and the size of the overlay.

Virtual Memory A history Virtual memory was developed in approximately 1959–1962, at the University of Manchester for the Atlas Computer, completed in 1962. In 1961, Burroughs released the B5000, the first commercial computer with virtual memory. It used segmentation rather than paging. Virtual Memory was controversial and required many theories, models, and experiments before it was adopted. "the machine that everyone loves, and nobody buys" - Brian Randell

Virtual Memory A history Dynamic address translation required a specialized, expensive, and hard to build hardware Worries that new system-wide algorithms of utilizing secondary storage would be far less effective than application-specific ones. In 1969 an IBM research team led by David Sayre showed that the virtual memory overlay system consistently worked better than the best manually controlled systems.

Virtual Memory Pages Virtual memory address space is divided into pages. A page is a block of contiguous virtual memory addresses that are at least 4096 bytes in size. Pages are managed by Page Tables. Page Tables are kept in memory and translate virtual addresses into physical addresses for use by the hardware. A Page Directory manages Page Tables. There is one page directory per operating system.

Visualization of Paging System in Windows NT (32 bit)‏ Page Directory Entry Offset (Per Process)‏ Page Table Entry Offset (Table + Frame)‏ Memory byte offset (4096 bytes in frame)‏

Virtual Memory Paging “Swapping” is the act of swapping data from physical memory into the virtual memory portion of the hard drive. “Paging” is the act of reading data from the hard drive (not the virtual memory portion) and writing data permanently back to the hard drive. Some Operating Systems use “Paging” to describe both (Windows and its “pagefile” vs Unix and its “swap”)‏

Virtual Memory Page Fault A Page Fault occurs when a program attempts to access a page that is not current in main memory. The operating system takes over and does the following: 1. Determines the location of the data in secondary storage. 2. Creates an empty page frame in main memory. 3. Loads the data into the empty page frame. 4. Updates the Page Table to show the new data. 5. Return control to the program, retrying the last instruction which caused the page fault.

Virtual Memory Page Fault If main memory is full in step 2: Swap out page in memory using an algorithm (most commonly used is discarding based on Least Recently Used)‏ A Page is “Dirty” if it has been modified since it was read from secondary storage. If Page is “Dirty”, the OS writes the changes back to secondary storage. Else, the OS just discards the page. When Page Fault swapping occurs, OS attempts to predict which pages will be used later and load those at the same time.

Virtual Memory Paging Strategies Demand Paging: No pages are loaded into RAM unless specifically requested by the program. Program starts with NO pages loaded into RAM. Pages of program of the program that are not run will never be loaded.

Virtual Memory Paging Strategies Loader Paging: Attempts to predict which parts of the program will be loaded. If possible, every page of the program will be loaded into memory at the start of execution.

Virtual Memory Paging Strategies Anticipatory Paging: Uses the locality of reference to pre-load pages from the program that are most likely to be executed. The goal is to minimize the number of page faults.

Virtual Memory Paging Strategies Swap Prefetch: A type of anticipatory paging which specifically pre-loads pages Pre-loads pages from program that caused last pagefault. Pre-loads pages that have been swapped out back into memory when a large program releases it's memory in anticipation of the user needing to use the other programs instead.

Virtual Memory Paging Strategies Pre-cleaning: Writes “Dirty” pages back into secondary storage periodically as a syncing mechanism, before page needs to be swapped out. Makes starting a new program much faster as pages that were “Dirty” and would have to be written back to secondary storage are now clean and are just discarded.

Virtual Memory Paging Replacement Algorithms Theoretical Optimal Paging Algorithm First In, First Out Second Chance (Special case of FIFO)‏ Clock (Similar to Second Chance)‏ Least Recently Used Not Frequently Used Aging (Combines LRU with NFU)‏ Random

Virtual Memory Thrashing Thrashing is when the Operating System spends more and more time swapping pages to and from virtual memory on the hard drive than running the program Occurs when the sum of localities from running processes cannot all fit into main memory. When a computer is using more and more resources for a decreasing amount of work done, it is said to be thrashing.

Virtual Memory Thrashing Solutions for Thrashing: Increase size of main memory Reduce number of concurrent processes running Reduce the size of concurrent processes running