현재이이미지를표시할수없습니다. Chapter 9: Virtual Memory

Similar documents
CSE 4/521 Introduction to Operating Systems. Lecture 15 Virtual Memory I (Background, Demand Paging) Summer 2018

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

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

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

Chapter 9: Virtual Memory

Chapter 9: Virtual-Memory

Chapter 8: Virtual Memory. Operating System Concepts

Virtual Memory Silberschatz: 9. Operating Systems. Autumn CS4023

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

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

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

Chapter 9: Virtual Memory

CS420: Operating Systems

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

Virtual Memory - I. Roadmap. Background. Demand Paging. valid-invalid bit. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012

CS370 Operating Systems

Virtual Memory Outline

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

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

Chapter 10: Virtual Memory

Chapter 3: Virtual Memory ว ตถ ประสงค. Background สามารถอธ บายข อด ในการท ระบบใช ว ธ การจ ดการหน วยความจ าแบบเสม อนได

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

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

Operating System Concepts 9 th Edition

Module 9: Virtual Memory

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

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory. Demand Paging

OPERATING SYSTEM. Chapter 9: Virtual Memory

Chapter 9: Virtual Memory

CS370 Operating Systems

CS307: Operating Systems

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

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory

Chapters 9 & 10: Memory Management and Virtual Memory

Chapter 9: Virtual Memory

Multi-Process Systems: Memory (2) Memory & paging structures: free frames. Memory & paging structures. Physical memory

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

CS370 Operating Systems

Chapter 8: Main Memory. Operating System Concepts 8th Edition

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

Chapter 6: Demand Paging

Operating System - Virtual Memory

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

Basic Memory Management

Chapter 9: Virtual Memory

Virtual Memory COMPSCI 386

ADRIAN PERRIG & TORSTEN HOEFLER Networks and Operating Systems ( ) Chapter 6: Demand Paging

Module 9: Virtual Memory

Chapter 10: Virtual Memory. Background

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

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Operating System Concepts

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

Memory Management and Protection

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Where are we in the course?

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

Module 8: Memory Management

Chapter 9: Virtual Memory

Course: Operating Systems Instructor: M Umair. M Umair


Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Even in those cases where the entire program is needed, it may not all be needed at the same time (such is the case with overlays, for example).

Last class: Today: Paging. Virtual Memory

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Logical versus Physical Address Space

Frequently asked questions from the previous class survey

VIRTUAL MEMORY READING: CHAPTER 9

Virtual Memory CHAPTER CHAPTER OBJECTIVES. 8.1 Background

Principles of Operating Systems

Processes and More. CSCI 315 Operating Systems Design Department of Computer Science

VII. Memory Management

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

Chapter 8: Memory- Management Strategies

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

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition

Virtual Memory. ICS332 Operating Systems

Chapter 8: Main Memory

Introduction to Virtual Memory Management

Operating Systems. No. 9 ศร ณย อ นทโกส ม Sarun Intakosum

Chapter 8 Memory Management

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

Chapter 8: Main Memory

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

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

Chapter 3: Processes

CS 134: Operating Systems

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.

Chapter 3: Processes. Operating System Concepts 8 th Edition,

Page Replacement Algorithms

Chapter 3: Processes. Operating System Concepts 9 th Edit9on

Chapter 8: Memory Management Strategies

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

Chapter 3: Process-Concept. Operating System Concepts 8 th Edition,

Page Replacement Chap 21, 22. Dongkun Shin, SKKU

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

UNIT - IV. What is virtual memory?

Chapter 8: Main Memory

Transcription:

현재이이미지를표시할수없습니다. Chapter 9: Virtual Memory

Objectives To describe the benefits of a virtual memory system To explain the concepts of demand paging, page-replacement algorithms, and allocation of page frames To discuss the principle of the working-set model 9.2 Silberschatz, Galvin and Gagne 2009

Evolution of Memory System 9.3 Silberschatz, Galvin and Gagne 2009

Background : Virtual Memory Virtual memory The separation of user logical memory from physical memory. There is no static 1:1 match between physical memory address vs. logical memory address. Then, how can we find proper memory location? Page Table! Through the page table, each logical address can be mapped into different physical address Only some parts of the program are needed to be in memory for execution. Logical address space can therefore be much larger than physical address space. Helps to allows address spaces to be shared by several processes. E.g., page sharing or segment sharing 9.4 Silberschatz, Galvin and Gagne 2009

Background : Virtual Memory Virtual memory can be implemented via: Demand paging Demand segmentation 9.5 Silberschatz, Galvin and Gagne 2009

Virtual Address Space Virtual address space of process refers to logical view of how process is stored in memory. A process is assumed to address between 0 to MAX A (logical) process begins at a certain logical address, say address 0, and exists in continuous memory. The space between stack and heap is a part of a virtual address space, but it will only require actual physical pages only if stack or heap grows. 9.6 Silberschatz, Galvin and Gagne 2009

Virtual Memory that is Larger than Physical Memory Continuou s address non-continuous address Some parts are resided in disk 9.7 Silberschatz, Galvin and Gagne 2009

Virtual Memory that is Larger than Physical Memory 9.8 Silberschatz, Galvin and Gagne 2009

Need for Block Mapping 9.9 Silberschatz, Galvin and Gagne 2009

Demand Paging Page is needed Page is referenced by a process In-memory but invalid reference abort Due to page replacement, page protection (such as readonly), etc. Not-in-memory bring to memory (miss penalty) Demanding paging Similar to paging system with swapping where processes can reside in secondary storage (usually disk). Swap partition can be treated as the extension of main memory. Can be non continuous in physical memory AND can be resided in disk 9.10 Silberschatz, Galvin and Gagne 2009

Demand Paging Bring a page into memory only when it is needed Less I/O needed Less memory needed Faster response More users More concurrent programs 9.11 Silberschatz, Galvin and Gagne 2009

Swapper vs. Pager In virtual memory system, we usually use Lazy Swapper, which never swaps a page into memory unless that page will be needed. Swapper vs. Pager Swapper : Since we are now viewing a process as a sequence of pages, rather than as one continuous address space, swapper is technically incorrect. Swapper manipulates an entire process. Pager is concerned with the individual pages of a process. In virtual systems, we thus use pager, rather than swapper. 9.12 Silberschatz, Galvin and Gagne 2009

Transfer of a Paged Memory to Disk Space 9.13 Silberschatz, Galvin and Gagne 2009

Valid-Invalid Bit With each page table entry, a valid invalid bit is associated (1 in-memory, 0 not-in-memory) Initially, valid invalid bit is set to 0 on all entries Example of a page table snapshot: Frame # M page table valid-invalid bit 1 1 1 1 0 0 0 During address translation, if valid invalid bit in page table entry is 0 page fault 9.14 Silberschatz, Galvin and Gagne 2009

Page Table When Some Pages Are Not in Main Memory In chapter 8, we use valid bit to decide whether the referenced address is legal process space or not. In virtual memory, valid bit is used to decide Valid=1; associated page is both legal and in memory. Valid=0; illegal or (legal but not in memory) page fault. 9.15 Silberschatz, Galvin and Gagne 2009

Page Table When Some Pages Are Not in Main Memory In virtual memory, the number of page table entries is just the number of required pages for each process. different page table length is possible (PTLR is required) c.f., in slide 8.58, In real memory, page table should cover all address space of main memory. 9.16 Silberschatz, Galvin and Gagne 2009

Implementation of Page Table Depending on the existence of PTLR If no existence There is no ways to distinguish that valid = 0 means Illegal address access or legal but not in memory Additional information bit is required. If existence There is no illegal access, so valid = 0 means that the page is not in memory Page Fault routine starts. Except the page table, Page Frame Table (i.e., Memory Table) is required, to trace whole memory usage. compare with slide 8.59 9.17 Silberschatz, Galvin and Gagne 2009

Page Fault If there is ever a reference to a page, first reference will trap to OS Page Fault OS looks at another table field, such as protection bit or valid bit to decide: By protection bit, Invalid reference trap (i.e., address space violation or read/write violation) By valid bit, Not in memory page fault Get empty frame. Swap page into frame. Restart table access with validation bit = 1. 9.18 Silberschatz, Galvin and Gagne 2009

Steps in Handling a Page Fault 9.19 Silberschatz, Galvin and Gagne 2009

What happens if there is no free frame? Page replacement find some pages in memory, but not really in use, swap it out Which Algorithm? Performance want an algorithm which will result in minimum number of page faults Same page may be brought into memory several times 9.20 Silberschatz, Galvin and Gagne 2009

Performance of Demand Paging Page Fault Rate 0 p 1.0 if p = 0 no page faults if p = 1, every reference is a fault Effective Access Time (EAT) EAT = (1 p) x memory access + p x {(page fault overhead) + (swap page out) + (swap page in) + (restart overhead)} 9.21 Silberschatz, Galvin and Gagne 2009

Demand Paging Example Suppose Memory access time = 200 nanoseconds Average page-fault service time = 8 milliseconds EAT = (1 p) x (200 nanoseconds) + p x (8 milliseconds) = (1 p ) x 200 + p x 8,000,000 = 200 + p x 7,999,800 If one access out of 1,000 causes a page fault, 200 + 0.001 x 7,999,800 = 8199.8 (i.e., EAT = 8.2 microseconds) This is a slowdown by a factor of about 40!! (why? 200 nano memory access time vs. 8199 nano page fault service time) 9.22 Silberschatz, Galvin and Gagne 2009

Demand Paging Example So what? Page fault is a critical factor in virtual memory systems. So, we must reduce page faults In other words, we must use a good page replacement algorithm 9.23 Silberschatz, Galvin and Gagne 2009

Some Benefits of Virtual Memory Virtual memory allows other benefits during process creation: - Page Sharing - Copy-on-Write - Memory-Mapped Files (later, slide 9.66) 9.24 Silberschatz, Galvin and Gagne 2009

Page Sharing Shared Library Using Virtual Memory Virtual memory also allows files and memory to be shared by two or more processes through page sharing. 9.25 Silberschatz, Galvin and Gagne 2009

Copy-on-Write Copy-on-Write (COW) allows both parent and child processes to initially share the same pages in memory If either process modifies a shared page, only then the page is copied therefore, it is called as Copy-on-Write. COW allows more efficient process creation because only modified pages are copied (forked) Free pages are allocated from a pool of zeroed-out pages (i.e., no need to write back into disk) Silence replacement 9.26 Silberschatz, Galvin and Gagne 2009

Copy-on-Write Before process 1 modifies page C 9.27 Silberschatz, Galvin and Gagne 2009

Copy-on-Write After process 1 modifies page C 9.28 Silberschatz, Galvin and Gagne 2009

Page Replacement Need for Page Replacement Physical memory full how can we treat the page B and M? Memory full 9.29 Silberschatz, Galvin and Gagne 2009