VIRTUAL MEMORY Virtual Address Space. In computing, virtual address space (abbreviated VAS) is a memory mapping mechanism available in modern operating.

Slides:



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

9.4 Page Replacement What if there is no free frame?
Chapter 11 – Virtual 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.
Virtual Memory: Page Replacement
Scribe for 7 th April 2014 Page Replacement Algorithms Payal Priyadarshini 11CS30023.
Basic Memory Management Monoprogramming Protection Swapping Overlaying OS space User space.
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
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.
Allocating 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)
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
CS 104 Introduction to Computer Science and Graphics Problems
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 Lecture 9: Virtual Memory Operating System I Spring 2007.
Memory Management Virtual Memory Page replacement algorithms
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 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
Slide 12-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter Virtual Memory.
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.
Silberschatz and Galvin  Chapters 3 and 5 Possible questions –Tracing a given program involving fork, exec, semaphores, and share memory –Wring.
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
Memory Management Techniques
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.
Subject: Operating System.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Chapter 8 Virtual Memory Operating Systems: Internals and Design Principles Seventh Edition William Stallings.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 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.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Memory Management & Virtual Memory © Dr. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada.
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.
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
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.
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.
Page Replacement FIFO, LIFO, LRU, NUR, Second chance
Chapters 3 and 5 Possible questions
Logistics Homework 5 will be out this evening, due 3:09pm 4/14
Virtual memory.
Chapter 2 Memory and process management
UNIT–IV: Memory Management
ITEC 202 Operating Systems
Instructor: Junfeng Yang
Lecture 10: Virtual Memory
Review.
Main Memory Management
Memory Management & Virtual Memory
Lecture 39 Syed Mansoor Sarwar
Contents Memory types & memory hierarchy Virtual memory (VM)
Computer Architecture
Page Replacement FIFO, LIFO, LRU, NUR, Second chance
Operating Systems Concepts
COMP755 Advanced Operating Systems
Chapter 9: Virtual Memory CSS503 Systems Programming
Module IV Memory Organization.
Presentation transcript:

VIRTUAL MEMORY Virtual Address Space

In computing, virtual address space (abbreviated VAS) is a memory mapping mechanism available in modern operating systems such as OpenVMS, UNIX, Linux, and Windows NT.address spacememory operating systemsOpenVMSUNIXLinux Windows NT This is beneficial for different purposes, one is security through process isolation. An address generated by the process is called logical address (virtual address) and it is mapped to the virtual address space.process isolationlogical address Source: Wikipedia

Page translation in books You write a manuscript that is 325 lines long. You give it to a publisher and they publish it in a book that has pages with 32 lines each. Example) If you wanted to find line 135 in your manuscript and you have a copy of your book, where would the line be (assuming the first page is page 0 and the first line on each page is line 0)? Answer) use page translation Page = RoundUp(135/32) - 1 = page 4 (the 5 th page) Offset into the page = 135 mod 32 = 7 (the 8 th line) So it is on page 4, then go to line 7.

Section Table for a Process

Page table for a process

Memory picture

Paging/Segmented System

Fragmentation In computer storage, fragmentation is a phenomenon in which storage space is used inefficiently, reducing capacity and often performance. Fragmentation leads to storage space being "wasted", and the term also refers to the wasted space itself.computer storage Source: wikipedia

Minimizing Fragmentation

Address Translation

Questions on address translation

Storage selection for segments/pages Best Fit Find the open block of consecutive page frames in MM that best fits the storage incoming storage location. Advantages: Finds tightly fitted locations which will allow large open consecutive blocks for larger processes that may come in later Disadvantages: - Must check all open blocks of page frames which will take processing time First Fit Find the open block of consecutive page frames in MM that first fits (starting from the beginning of memory to the end) Advantages: Does not need to check all available spaces, since as soon as the first on is found. Worst fit Find the open block of consecutive page frames in MM that worst fits (biggest block of available free page frames) storage the incoming storage location. Advantages: Finds tightly fitted locations which will allow large open consecutive blocks for larger processes that may come in later Disadvantages: - Must check all open blocks of page frames, which will take processing time.

Example: contiguous storage

Page Replacement Suppose the OS allocates a fixed number of page frames to a process. If a page from a process is referenced by the process, and it is not currently in memory (this is called a page fault) then a page frame from that process must be selected for removal so the newly referenced page can be put in memory. Which page frame should be selected? Local Replacement When a process needs to bring in a page to memory, the page selected for removal is chosen from the set of pages currently in memory for that same process. Global Replacement When a process needs to bring in a page to memory, the page selected for removal is chosen from the set of all pages currently in memory for any process.

First or Last in First Out FIFO (First In First Out) Method: Select the frame that has been in MM the longest and remove it to make room. Implementation: maintain a linked list of all pages currently in MM and remove the page that is pointed to by the head of the linked list LIFO (Last In First Out) Method: Select the frame that has been in MM the shortest and remove it to make room. Implementation: maintain a linked list of all pages currently in MM and remove the page that is pointed to by the tail of the linked list.

Statistics based (Least Recently used) LRU (Least Recently Used) Method: Select the frame that has been referenced the least recently of all frames in MM. Implementation: Maintain a linked list of all pages currently in MM and each time a page is referenced, move the page to the front of the linked list.

Not Used Recently NUR (Not Used Recently) Method: Select the frame that has been referenced the somewhat least recently of all frames in MM. This method is that same idea as LRU but the implementation is much simpler. Implementation: Maintain an array of bits for each page, when a page is referenced, set the bit to 1. At the time when a page reference will set all bits to 1 (meaning every page in MM has a bit of 1) then set all reference bits to zero to start the whole reference recording over. At the time of removal selection, pages that have not been referenced recently will have the reference bit set to 0.

Second Chance Method: Same as NUR but with 2 bits. At the time when a page is selected, it is given a second chance, the second chance bit is turned on and it not selected for removal. Implementation: Maintain 2 arrays of bits for each page, just like the NUR but when a page is selected, check if the second chance bit is set, if not, set it, and skip over this process an continue the selections process.

Optimal Page Replacement Optimal Method: Look into the future at the pages that will be referenced, and of all the pages currently in memory, select the page that’s next reference will be the furthest in the future. Implementation: Predict the future. The OS must know the exact sequence of referenced that the process will make. Not feasible if the program has if…then…else statements. Possible if the process is a straight process without decisions. Comment: Although this is not realistic to implement, it is the benchmark to check other algorithms against. That is, if the optimal algorithm produces x page faults, you would compare other algorithms against x.

Example: page reference string Consider a process in MM where the OS has given the process 3 page frames of MM to process out of but the process has a total of four pages. When a process is running, the list of pages referenced in order is called the reference string for the process. Suppose the reference for this process is 1,2,3,4,3,4,2,1,3,4 and the following page replacements are used.

Example using FIFO

Example using LIFO

Example using LRU

Example using Optimal

Working Set (see queuing theory) The working set principle take into account that whichever page replacement algorithm used, to maximize overall throughput, the goal is to have the processor(s) running as close to 100% of the time. A state where all processes are waiting for the disk drives for a page and none are “ready to run” should be avoided.