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

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

Chapters 9 & 10: Memory Management and Virtual Memory

Paging, and segmentation

Chapter 8 Main Memory

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

CS399 New Beginnings. Jonathan Walpole

Memory Management. Memory Management

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

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

Operating Systems. 09. Memory Management Part 1. Paul Krzyzanowski. Rutgers University. Spring 2015

Operating Systems Lecture 6: Memory Management II

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

CSE 421/521 - Operating Systems Fall Lecture - XII Main Memory Management. Tevfik Koşar. University at Buffalo. October 18 th, 2012.

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

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

The Memory Management Unit. Operating Systems. Autumn CS4023

Chapter 3 Memory Management: Virtual Memory

Performance of Various Levels of Storage. Movement between levels of storage hierarchy can be explicit or implicit

Memory Management. Dr. Yingwu Zhu

Chapter 8: Main Memory

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

Lecture 7. Memory Management

Recall from Tuesday. Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS.

Address spaces and memory management

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

Part Three - Memory Management. Chapter 8: Memory-Management Strategies

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation

Basic Memory Management

Operating Systems. Paging... Memory Management 2 Overview. Lecture 6 Memory management 2. Paging (contd.)

a. What is a lower bound on the number of page faults? b. What is an upper bound on the number of page faults?

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

Recap: Memory Management

Module 9: Virtual Memory

Chapter 8: Main Memory

Operating Systems: Internals and Design Principles. Chapter 7 Memory Management Seventh Edition William Stallings

Goals of Memory Management

8.1 Background. Part Four - Memory Management. Chapter 8: Memory-Management Management Strategies. Chapter 8: Memory Management

CS 31: Intro to Systems Virtual Memory. Kevin Webb Swarthmore College November 15, 2018

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

Operating Systems Memory Management. Mathieu Delalandre University of Tours, Tours city, France

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

Memory Management. Memory Management

Operating Systems. User OS. Kernel & Device Drivers. Interface Programs. Memory Management

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

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time

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

Memory management: outline

Memory management: outline

Introduction to Virtual Memory Management

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

Lecture 8 Memory Management Strategies (chapter 8)

CS450/550 Operating Systems

Chapter 8: Memory Management Strategies

CS420: Operating Systems

Chapter 10: Virtual Memory. Background

CS 153 Design of Operating Systems Winter 2016

Move back and forth between memory and disk. Memory Hierarchy. Two Classes. Don t

Memory Management Ch. 3

12: Memory Management

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

Memory Management william stallings, maurizio pizzonia - sistemi operativi

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

Where are we in the course?

Operating Systems (2INC0) 2017/18

Memory Management. Memory Management Requirements

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY

Modeling Page Replacement: Stack Algorithms. Design Issues for Paging Systems

MODERN OPERATING SYSTEMS. Chapter 3 Memory Management

Chapter 8: Memory Management

Operating System Principles: Memory Management Swapping, Paging, and Virtual Memory CS 111. Operating Systems Peter Reiher

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

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

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems 3rd edition Uses content with permission from Assoc. Prof. Florin Fortis, PhD

Memory Management. Goals of Memory Management. Mechanism. Policies

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

Chapter 8 Memory Management

Module 9: Virtual Memory

Chapter 9: Memory Management. Background

Module 8: Memory Management

Module 9: Memory Management. Background. Binding of Instructions and Data to Memory

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

Chapter 8: Memory Management

Operating Systems (2INC0) 2017/18

Last class: Today: Paging. Virtual Memory

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

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

MEMORY MANAGEMENT. Jo, Heeseung

Memory Management. Jo, Heeseung

CS307: Operating Systems

Chapter 3: Important Concepts (3/29/2015)

Virtual Memory I. Jo, Heeseung

Memory management OS

Chapter 9. Storage Management

Virtual Memory 1. Virtual Memory

Memory Management Virtual Memory

Virtual Memory 1. Virtual Memory

Lecture 12: Demand Paging

Operating Systems Unit 6. Memory Management

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

Transcription:

Computer Systems II Memory Management" Memory Management" Subdividing memory to accommodate many processes A program is loaded in main memory to be executed Memory needs to be allocated efficiently to pack as many processes into memory as possible Memory management requirements Relocation Protection

Relocation" The programmer doesn t know where the program will be placed in memory when it is executed Physical memory references cannot be fixed It is necessary to distinguish between logical address and physical address : Logical address generated by the CPU; also referred to as virtual address Physical address address seen by the memory unit The compiler generates logical addresses Hardware Support for Relocation"

Protection" User processes cannot be allowed to read or write outside their boundaries Protection must be done at runtime Programs can be loaded anywhere in memory Programs can dynamically allocate memory Check for valid addresses during address translation Verify that address is within its bound Hardware Support for Protection"

Relocation and Protection Exercise" ax " CPU" MMU" Limit " Relocation " " Main memory" bx " " mov ax, ()" IR " mov ax, ()" PC " " " x" " Memory Partitioning Paging"

Simple Paging" Memory is divided into small page frames Pages of process are loaded into frames (need not be contiguous) Less external fragmentation Small pages limit internal fragmentation Page table translates page addresses to frames Frame Main Memory Simple Paging (Example)" Load pages into empty frames Sufficient frames must exist for entire process No compaction needed (pages can be loaded into non-contiguous frames) Frame Main Memory Process A D () () Process A D () () Process A D () () Process A D () () Process B () Process B () Process B () Process B () Process B () Process B () Process C () Process C () Process C () Process C () Process D () Process D ()

Page Tables" One page table for each process Page table translates logical addresses to physical addresses Process B Page Frame Process C Page Frame Process D Page Frame Frame Main Memory Process A D () () Process A D () () Process A D () () Process A D () () Process B () Process B () Process B () Process B () Process B () Process B () Process C () Process C () Process C () Process C () Process D () Process D () Logical to Physical Translation" Translation done in hardware Upper N bits translated to frame number Lower M bits contain offset into page Page Number Page Offset Logical Address Page Page Table Frame Number Page Offset Frame Number Page Page Physical Address...

Address Translation" Page number p Page offset d Use the page # to index the page table and append the offset to the frame # Address Translation Example"

Virtual Memory" Problems with Memory Allocation" In simple paging all pages must be loaded Limits the number of active processes External fragmentation still possible Swapping is a time consuming process Solution: Virtual Memory Load pages only when needed Less need to swap processes out to disk Virtual memory allows the OS to load pieces only when needed (demand paging)

Virtual Addressing" Virtual (logical) address is mapped to a real address using a page table Size of physical address limited by memory size What limits the size of a Virtual address?? Page Number Offset Virtual Address Page table mapping Frame Number Offset Physical Address Backing Store on Disk" Pages not in main memory are stored in a dedicated swap area on disk Main Memory Pages Page table Disk Swap Area

Demand Paging" Only load those pages needed by process Keep a permanent store of pages on disk Allows more processes to be active Eliminates needless loading and unloading Frame Main Memory Process A () Process A () Process D () Process B () Process C () Process D () Process E () Process C () Process F () Process G () Process B () Process H () Process I () Process J () Process E () Process J () Page Table Structure" Extra control information needed Presence bit: indicates whether page is loaded Dirty bit: indicates whether page has been modified other control (I.e. protection) During address translation, if bit in page table entry is invalid page fault Frame # Presence bit page table

Page fault" Occurs when a process accesses a page not in memory Initial page fault processing When page is loaded: Block current process Memory Full? No Setup I/O HW to read page from disk Start a new ready process yes Evict a page from memory Page loaded? yes Update page table Mark process ready No Aside: Programming Considerations" Program structure int A[][]; Assume each row is stored in one page Program : page faults for (j = ; j < ; j++) for (i = ; i < ; i++) A[i][j] = ; Program : page faults for (i = ; i < ; i++) for (j = ; j < ; j++) A[i][j] = ;

Replacement Policy" Process A attempts to execute: mov (ebx), ecx Register ebx contains an address that corresponds to page of process A What happens? Frame Main Memory Process A () Process A () Process D () Process B () Process C () Process D () Process E () Process C () Process F () Process G () Process B () Process H () Process I () Process J () Process E () Process J () Replacement Policy" Most studied memory policy Goal is to replace page needed furthest in the future (minimize page faults) Policies include: Optimal: Not possible but something to try for Least recently used (LRU) First-in, first-out (FIFO) Clock: tries to approximate LRU Some pages not subject to replacement Frames are locked

Least-Recently-Used (LRU)" Replace the page that was referenced furthest in the past Assumes that the past reflects the future Requires an update on every reference keep the time or update the reference list Four page replacements for example Page Address Stream F F F F This Lecture" Relocation and Protection Simple Paging Virtual Memory