VIRTUAL MEMORY. Maninder Kaur. 1

Similar documents
Operating Systems Lecture 6: Memory Management II

Page Replacement. 3/9/07 CSE 30341: Operating Systems Principles

Page Replacement Algorithms

Memory Organization MEMORY ORGANIZATION. Memory Hierarchy. Main Memory. Auxiliary Memory. Associative Memory. Cache Memory.

Memory Management. 3. What two registers can be used to provide a simple form of memory protection? Base register Limit Register

Operating System - Virtual Memory

Module 9: Virtual Memory

Virtual Memory. Virtual Memory. Demand Paging. valid-invalid bit. Virtual Memory Larger than Physical Memory

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Basic Page Replacement

Module 9: Virtual Memory

Background. Virtual Memory (2/2) Demand Paging Example. First-In-First-Out (FIFO) Algorithm. Page Replacement Algorithms. Performance of Demand Paging

Chapter 9: Virtual Memory

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

Virtual Memory Demand Paging. Virtual Memory Working Set Model

CS510 Operating System Foundations. Jonathan Walpole

Memory Management. Virtual Memory. By : Kaushik Vaghani. Prepared By : Kaushik Vaghani

Virtual Memory. Today.! Virtual memory! Page replacement algorithms! Modeling page replacement algorithms

Demand Paging. Valid-Invalid Bit. Steps in Handling a Page Fault. Page Fault. Transfer of a Paged Memory to Contiguous Disk Space

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

First-In-First-Out (FIFO) Algorithm

Chapter 4 Memory Management

Paging algorithms. CS 241 February 10, Copyright : University of Illinois CS 241 Staff 1

Introduction to Virtual Memory Management

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.

CSC Operating Systems Spring Lecture - XIV Virtual Memory - II. Tevfik Ko!ar. Louisiana State University. March 27 th, 2008.

Chapter 9: Virtual-Memory

CS 550 Operating Systems Spring Memory Management: Page Replacement

Chapter 9: Virtual Memory

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

Chapter 9: Virtual-Memory Management. Operating System Concepts 8 th Edition,

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

MODERN OPERATING SYSTEMS. Chapter 3 Memory Management

Optimal Algorithm. Replace page that will not be used for longest period of time Used for measuring how well your algorithm performs

Paging and Page Replacement Algorithms

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

Virtual Memory: Page Replacement. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

Chapter 8 Virtual Memory

Chapter 10: Virtual Memory. Background

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

The Memory System. Components of the Memory System. Problems with the Memory System. A Solution

CSE325 Principles of Operating Systems. Virtual Memory. David P. Duggan. March 7, 2013

Background. Demand Paging. valid-invalid bit. Tevfik Koşar. CSC Operating Systems Spring 2007

Chapter 10: Virtual Memory. Background. Demand Paging. Valid-Invalid Bit. Virtual Memory That is Larger Than Physical Memory

Chapter 8: Virtual Memory. Operating System Concepts

Last Class. Demand Paged Virtual Memory. Today: Demand Paged Virtual Memory. Demand Paged Virtual Memory

I/O Management and Disk Scheduling. Chapter 11

Chapter 9: Virtual Memory

CS 4410 Operating Systems. Page Replacement (2) Summer 2016 Cornell University

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

Memory Management Prof. James L. Frankel Harvard University

Chapter 11 I/O Management and Disk Scheduling

Virtual Memory III. Jo, Heeseung

Virtual Memory. Chapter 8

Perform page replacement. (Fig 8.8 [Stal05])

Computer Systems II. Memory Management" Subdividing memory to accommodate many processes. A program is loaded in main memory to be executed

Chapter 9: Virtual Memory

Virtual Memory - Overview. Programmers View. Virtual Physical. Virtual Physical. Program has its own virtual memory space.

Chapter 9: Virtual Memory. Chapter 9: Virtual Memory. Objectives. Background. Virtual-address address Space

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - XIV Virtual Memory - I. Louisiana State University.

a process may be swapped in and out of main memory such that it occupies different regions

Lecture 14 Page Replacement Policies

Virtual Memory Design and Implementation

Chapter 9: Virtual Memory

CISC 7310X. C08: Virtual Memory. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/22/2018 CUNY Brooklyn College

Address spaces and memory management

Virtual Memory - II. Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XVI. University at Buffalo.

Virtual Memory COMPSCI 386

CS420: Operating Systems

Where are we in the course?

Virtual Memory. Reading: Silberschatz chapter 10 Reading: Stallings. chapter 8 EEL 358

OPERATING SYSTEM. Chapter 9: Virtual Memory

CS370 Operating Systems

Principles of Operating Systems

Subject Teacher: Prof. Sheela Bankar

Page replacement algorithms OS

MEMORY MANAGEMENT/1 CS 409, FALL 2013

Cache Memory Mapping Techniques. Continue to read pp

DAT (cont d) Assume a page size of 256 bytes. physical addresses. Note: Virtual address (page #) is not stored, but is used as an index into the table

Operating Systems. Operating Systems Sina Meraji U of T

Memory management, part 2: outline. Operating Systems, 2017, Danny Hendler and Amnon Meisels

Memory: Paging System

CS370 Operating Systems

Chapter 4 Memory Management. Memory Management

Lecture 17. Edited from slides for Operating System Concepts by Silberschatz, Galvin, Gagne

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

Lecture 12: Demand Paging

Memory management, part 2: outline

CS370 Operating Systems

CPE300: Digital System Architecture and Design

CS 153 Design of Operating Systems Winter 2016

Chapter 4: Memory Management. Part 1: Mechanisms for Managing Memory

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

EECS 482 Introduction to Operating Systems

Operating System Concepts 9 th Edition

All Paging Schemes Depend on Locality. VM Page Replacement. Paging. Demand Paging

Fig 7.30 The Cache Mapping Function. Memory Fields and Address Translation

COMP 346 WINTER 2018 MEMORY MANAGEMENT (VIRTUAL MEMORY)

Swapping. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Transcription:

VIRTUAL MEMORY Maninder Kaur professormaninder@gmail.com 1 www.eazynotes.com

What is Virtual Memory? The term virtual memory refers to something which appears to be present but actually it is not. The virtual memory technique allows users to use more memory for a program than the real memory of a computer. So, virtual memory is the concept that gives the illusion to the user that they will have main memory equal to the capacity of secondary storage media. 2 www.eazynotes.com

Concept of Virtual Memory A programmer can write a program which requires more memory space than the capacity of the main memory. Such a program is executed by virtual memory technique. The program is stored in the secondary memory. The memory management unit (MMU) transfers the currently needed part of the program from the secondary memory to the main memory for execution. This to and fro movement of instructions and data (parts of a program) between the main memory and the secondary memory is called Swapping. 3 www.eazynotes.com

Address Space And Memory Space Virtual address is the address used by the programmer and the set of such addresses is called the address space or virtual memory. An address in main memory is called a location or physical address. The set of such locations in main memory is called the memory space or physical memory. 4 www.eazynotes.com

Virtual Memory 5 www.eazynotes.com

Virtual Memory (cont.) 1. CPU generated logical address consisting of a logical page number plus the location within that page (x). 2. It must be mapped onto an actual (physical) main memory address by the operating system using mapper. 3. If the page is present in the main memory, CPU gets the requires data from the main memory. 4. If the mapper detects that the requested page is not present in main memory, a page fault occurs and the page must be read from secondary storage (4, 5) into a page frame in main memory. 6 www.eazynotes.com

Address Mapping Using Memory Mapping Page Table When the requested page is not available in the main memory, we can say that a page fault have been occurred in the main memory. Then the virtual address generated by the CPU is used to take out the requested page from the secondary storage media to the main memory to remove this page fault. If empty page frame is not available, then a page must be removed from page frame in main memory. 7 www.eazynotes.com

Page Replacement Algorithms In a computer operating system that uses paging for virtual memory management, page replacement algorithms decide which memory pages to page out (swap out, write to disk) when a page of memory needs to be allocated. Paging happens when a page fault occurs and a free page cannot be used to satisfy the allocation, either because there are none, or because the number of free pages is lower than some threshold. 8 www.eazynotes.com

First - In - First - Out (FIFO) First-in-first-out is very easy to implement. The FIFO algorithm selects the page for replacement that has been in memory the longest time. When a new page must be loaded, the page recently brought in is removed. The page to be removed is easily determined because its identification number is at the top of the FIFO stack. The FIFO replacement policy has the advantage of being easy to implement. It has the disadvantage that under certain circumstances pages are removed and loaded from memory too frequently. 9 www.eazynotes.com

FIFO Algorithm Consider a paging system having capacity of 3 pages. The execution of a program requires references to five distinct pages P 1, P 2, P 3, P 4 and P 5. The pages are executed in the following sequence: P 2 P 3 P 2 P 1 P 5 P 2 P 4 P 5 P 3 P 2 P 5 P 2 10 www.eazynotes.com

Least Recently Used (LRU) The least recently used page (LRU) replacement algorithm keeps track of page usage over a short period of time. The LRU algorithm can be implemented by associating a counter with every page that is in main memory. When a page is referenced, its associated counter is set to 0. At fixed intervals of time, the counters associated with all pages presently in memory are incremented by 1. The least recently used page is the page with the highest count. The counters are often called aging registers, as their count indicates their age, that is, how long their associated pages have been referenced. 11 www.eazynotes.com

LRU Algorithm Consider a paging system having capacity of 3 pages. The execution of a program requires references to five distinct pages P 1, P 2, P 3, P 4 and P 5. The pages are executed in the following sequence: P 2 P 3 P 2 P 1 P 5 P 2 P 4 P 5 P 3 P 2 P 5 P 2 12 www.eazynotes.com

Optimal (OPT) The optimal policy selects that page for replacement for which the time to the next reference is longest. This algorithm results in fewest number of page faults. But, this algorithm is impossible to implement. At the time of page fault, the operating system has no way of knowing when each of the pages will be referenced next. However, it does serve as a standard against which to judge other algorithms. 13 www.eazynotes.com

Optimal (OPT) Consider a paging system having capacity of 3 pages. The execution of a program requires references to five distinct pages P 1, P 2, P 3, P 4 and P 5. The pages are executed in the following sequence: P 2 P 3 P 2 P 1 P 5 P 2 P 4 P 5 P 3 P 2 P 5 P 2 14 www.eazynotes.com

15