Memory Management. Jo, Heeseung

Similar documents
MEMORY MANAGEMENT. Jo, Heeseung

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

Memory Management. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Chapter 7 Memory Management

Goals of memory management

Virtual Memory. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

The Memory Management Unit. Operating Systems. Autumn CS4023

Virtual Memory I. Jo, Heeseung

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

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

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

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

Chapters 9 & 10: Memory Management and Virtual Memory

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 358

Process. Memory Management

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Chapter 9: Memory Management. Background

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

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

Memory Management (1) Memory Management

Memory Management (1) Memory Management. CPU vs. memory. No.8. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

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

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

Chapter 8: Memory Management

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

Process. One or more threads of execution Resources required for execution

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

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University

Chapter 8: Main Memory

Preview. Memory Management

Chapter 8: Memory Management. Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging

UNIT III MEMORY MANAGEMENT

Chapter 8: Main Memory

Memory Management. Memory Management

Main Memory (Part I)

CS420: Operating Systems

Module 8: Memory Management

Memory Management. Goals of Memory Management. Mechanism. Policies

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

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

Chapter 8: Memory Management Strategies

CS153: Memory Management 1

Chapter 8: Memory Management

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

Module 8: Memory Management

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

Memory Management. Memory Management

Memory Management. Memory

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

Memory Management. Contents: Memory Management. How to generate code? Background

MEMORY MANAGEMENT/1 CS 409, FALL 2013

Operating Systems Unit 6. Memory Management

Background. Contiguous Memory Allocation

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

Lecture 7. Memory Management

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

Memory Management. Memory Management Requirements

CS370 Operating Systems

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

Last class: Today: Deadlocks. Memory Management

Operating systems. Part 1. Module 11 Main memory introduction. Tami Sorgente 1

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

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure.

CS307 Operating Systems Main Memory

12: Memory Management

Goals of Memory Management

CS307: Operating Systems

Chapter 8: Main Memory

Operating Systems (2INC0) 2017/18

Chapter 9 Memory Management

Lecture 8 Memory Management Strategies (chapter 8)

Chapter 8: Memory-Management Strategies

Logical versus Physical Address Space

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1

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

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Operating Systems and Computer Networks. Memory Management. Dr.-Ing. Pascal A. Klein

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

Chapter 8: Memory- Management Strategies

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

Introduction to Operating Systems

Chapter 9 Real Memory Organization and Management

Chapter 9 Real Memory Organization and Management

CS 3733 Operating Systems:

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

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

CSCI 4500 / 8506 Sample Questions for Quiz 5

Memory management OS

Memory Management. CSE 2431: Introduction to Operating Systems Reading: , [OSC]


CHAPTER 3 RESOURCE MANAGEMENT

6. Which of the following operating systems was the predecessor of Microsoft MS-DOS? a. Dynix b. Minix c. CP/M

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

Principles of Operating Systems

Memory Management william stallings, maurizio pizzonia - sistemi operativi

Chapter 8: Main Memory

General Objective:To understand the basic memory management of operating system. Specific Objectives: At the end of the unit you should be able to:

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems

CSE325 Principles of Operating Systems. Memory. David P. Duggan. March 6, 2010

Transcription:

Memory Management Jo, Heeseung

Today's Topics Why is memory management difficult? Old memory management techniques: Fixed partitions Variable partitions Swapping Introduction to virtual memory 2

Memory Management (1) Goals To provide a convenient abstraction for programming To allocate scarce memory resources among competing processes to maximize performance with minimal overhead To provide isolation between processes Why is it so difficult? 3

Single/Batch Programming An OS with one user process Programs use physical addresses directly OS loads job, runs it, unloads it 0xFFFF.. Operating System in ROM Device Drivers in ROM User Program User Program User Program 0 Operating System in RAM Operating System in RAM 4

Multiprogramming Multiprogramming Need multiple processes in memory at once - To overlap I/O and CPU of multiple jobs - Each process requires variable-sized and contiguous space Requirements - Protection: restrict which addresses processes can use - Fast translation: memory lookups must be fast, in spite of protection scheme - Fast context switching: updating memory hardware (for protection and translation) should be quick 5

Fixed Partitions (1) Partition 4 0x5000 Base register 0x2000 Partition 3 Partition 2 0x4000 Virtual address 0x0362 + 0x2362 Partition 1 0x3000 0x2000 Partition 0 Operating System 0x1000 0 6

Fixed Partitions (2) Physical memory is broken up into fixed partitions Size of each partition is the same and fixed The number of partitions = degree of multiprogramming Hardware requirements: base register Advantages - Physical address = virtual address + base register - Base register loaded by OS when it switches to a process Easy to implement, fast context switch Problems Internal fragmentation: memory in a partition not used by a process is not available to other processes Partition size: one size does not fit all - Fragmentation vs. Fitting large programs 7

Fixed Partitions (3) Improvement Partition size need not be equal Allocation strategies - Maintain a separate queue for each partition size - Maintain a single queue and allocate to the closest job whose size fits in an empty partition (first fit) - Search the whole input queue and pick the largest job that fits in an empty partition (best fit) IBM OS/MFT (Multiprogramming with a Fixed number of Tasks) Partition 4 Partition 2 Partition 1 Partition 0 Operating System 0x8000 0x4000 0x2000 0x1000 0 8

Variable Partitions (1) Limit register P1's Limit Base register P1's Base Partition 3 Virtual address offset <? Yes + Partition 2 Partition 1 No protection fault Partition 0 Operating System 9

Variable Partitions (2) Limit register P1's Limit Base register P1's Base Partition 3 Physical memory is broken up into variable-sized partitions IBM OS/MVT Hardware requirements: base register and limit register - Physical address = virtual address + base register - Base register loaded by OS when it switches to a process The role of limit register: protection - If (physical address > base + limit), then raise a protection fault Allocation strategies Virtual address First fit: Allocate the first hole that is big enough Best fit: Allocate the smallest hole that is big enough offset Worst fit: Allocate the largest hole <? No Yes protection fault + Partition 2 Partition 1 Partition 0 Operating System 10

Variable Partitions (3) Advantages No internal fragmentation Problems - Simply allocate partition size to be just big enough for process - But, if we break the physical memory into fixed-sized blocks and allocate memory in unit of block sizes (in order to reduce bookkeeping), we have internal fragmentation External fragmentation - As we load and unload jobs, holes are left scattered throughout physical memory Solutions to external fragmentation: - Compaction - Paging and segmentation 11

Overlays (1) Overlays for a two-pass assembler 12

Overlays (2) Overlays Keep in memory only those instructions and data that are needed at any given time Normally implemented by user Advantages Needed when a process is larger than the amount of memory allocated to it No special support needed from operating system Problems Complex - Programming design of overlay structure 13

Swapping (1) 14

Swapping (2) Swapping Swapped temporarily out of memory to a backing store Brought back into memory later for continued execution Backing store Problems - Fast disk - Large enough to accommodate copies of all memory images - Must provide direct access to these memory images Major part of swap time is transfer time - Directly proportional to the amount of memory swapped Swapping a process with a pending I/O? - Do not swap a process with pending I/O Modern OS uses modified swapping mechanisms (demand paging) with virtual memory 15

Virtual Memory (1) Example #include <stdio.h> int n = 0; int main () { printf ( &n = 0x%08x\n, &n); } %./a.out &n = 0x08049508 %./a.out &n = 0x08049508 16

Virtual Memory Concept 1 2 3 4 5 6 7 17

Virtual Memory Concept 1 5 2 5 3 4 5 5 6 5 7 18

Virtual Memory Concept 1 2 3 4 5 6 7 19

Virtual Memory Concept 1 2 3 4 5 6 7 20

Virtual Memory Concept 1 Process 2 3 4 5 6 7 OS & CPU with Page Table Virtual address Physical address 21

Virtual Memory (2) Virtual Memory (VM) Use virtual addresses for memory references - Large and contiguous CPU & OS perform address translation at run time - From a virtual address to the corresponding physical address Physical memory is dynamically allocated or released on demand - Programs execute without requiring their entire address space to be resident in physical memory - Lazy loading Virtual addresses are private to each process - Each process has its own isolated virtual address space - One process cannot name addresses visible to others 22

Virtual Memory (3) Virtual addresses To make it easier to manage memory of multiple processes, make processes use virtual addresses (logical addresses) Virtual addresses are independent of the actual physical location of data referenced OS determines location of data in physical memory Memory access procedures Instructions executed by the CPU issue virtual addresses Virtual addresses are translated by hardware into physical addresses (with help from OS) The set of virtual addresses that can be used by a process is its virtual address space There are many ways to translate virtual addresses into physical addresses 23

Virtual Memory (4) Advantages Separates user's logical memory from physical memory - Abstracts main memory into an extremely large, uniform array of storage - Frees programmers from the concerns of memory-storage limitations Allows the execution of processes that may not be completely in memory - Programs can be larger than physical memory - More programs could be run at the same time - Less I/O would be needed to load or swap each user program into memory Allows processes to easily share files and address spaces Efficient for protection and process creation 24

Virtual Memory (5) Disadvantages Performance!!! - In terms of time and space Implementation Paging Segmentation 25