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

Similar documents
Memory Management (1) Memory Management

The Memory Management Unit. Operating Systems. Autumn CS4023

CS420: Operating Systems

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

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

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

Main Memory (Part I)

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

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

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

Chapter 8: Memory Management

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

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

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

Chapter 8: Main Memory

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

Module 8: Memory Management

Chapter 8: Main Memory

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

Memory Management. Memory Management

Chapter 8: Memory Management Strategies

Chapter 9: Memory Management. Background

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

Module 8: Memory Management

Goals of Memory Management

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

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

Memory Management. (SGG, Chapter 08) Objectives. Memory Hierarchy. Outline. Instructor: Dr. Tongping Liu. To describe various memory hardware"

CS370 Operating Systems

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

COSC Operating Systems Design, Fall 2001, Byunggu Yu. Chapter 9 Memory Management (Lecture Note #8) 1. Background

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

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

CS307 Operating Systems Main Memory

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

12: Memory Management

Memory Management. Frédéric Haziza Spring Department of Computer Systems Uppsala University

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

CS307: Operating Systems

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

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

Chapter 8: Memory Management

Background. Contiguous Memory Allocation

Principles of Operating Systems

Logical versus Physical Address Space

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

CS 3733 Operating Systems:

Outlook. Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium

Memory Management (2)

CS399 New Beginnings. Jonathan Walpole

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

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

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

Chapter 8: Memory- Management Strategies

UNIT III MEMORY MANAGEMENT

Operating Systems Unit 6. Memory Management

Chapter 8: Main Memory

Operating Systems (2INC0) 2017/18

Chapter 8: Memory- Manage g me m nt n S tra r t a e t gie i s

Chapter 8: Memory-Management Strategies

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

9.1 Background. In Chapter 6, we showed how the CPU can be shared by a set of processes. As a result of

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

Chapter 8 Main Memory

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

P r a t t hr h ee e : e M e M m e o m r o y y M a M n a a n g a e g m e e m n e t 8.1/72

Lecture 8 Memory Management Strategies (chapter 8)

Memory Management. Jo, Heeseung

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

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

Course: Operating Systems Instructor: M Umair. M Umair

Main Memory Yi Shi Fall 2017 Xi an Jiaotong University

Chapter 9 Memory Management

Chapter 8: Main Memory

Chapter 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

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

Last Class: Deadlocks. Where we are in the course

SHANDONG UNIVERSITY 1

Chapters 9 & 10: Memory Management and Virtual Memory

UNIT-III VIRTUAL MEMORY

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

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

Lecture 7. Memory Management

Memory Management. Memory

MEMORY MANAGEMENT. Jo, Heeseung

Memory Management. Memory Management

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University


Introduction to Operating Systems

3. Memory Management

Memory Management. Memory Management Requirements

Process. Memory Management

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

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

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

Memory Management. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

Memory Management Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University

Memory Management. Dr. Yingwu Zhu

Chapter 7 Memory Management

Transcription:

EECS 3221 Operating System Fundamentals No.8 Memory Management (1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Memory Management A program usually resides on a disc as a binary executable file. The program can be moved between disk and memory. Program must be brought into memory and placed within a process for it to be executed. In multiprogramming, we keep several programs in memory. Memory management strategies: Contiguous Memory Allocation Paging Segmentation Segmentation with paging Memory management needs hardware support MMU. CPU vs. memory Physical memory consists of a large array of words or bytes, each with its own address. In a typical instruction-execution cycle: CPU fetches an instruction from memory according to PC. The instruction is decoded. CPU may fetch operands from memory according to the address in the instruction. (optional) CPU execute in registers CPU saves results into a memory address (optional) CPU generates address from program counter, program address, etc. CPU sends the address to a memory management unit (MMU), which is hardware to actually locate the memory at certain location. Memory protection. Memory mapping (address translation). 1

Program Generation & Address Symbolic address: e.g., count,i,j,etc Re-locatable address: e.g. 14 bytes from beginning of module Physical address: 0x14398, 0xFF083 Program Generation & Address Symbolic address: e.g., count,i,j,etc Re-locatable address: e.g. 14 bytes from beginning of module Logical address: e.g. 4014, 1058, etc. Physical address: 0x14398, 0xFF083 Logical vs. Physical Address Physical address: the address loaded into the memoryaddress register to actually address the memory. Logical (virtual) address: an address generated by the CPU and the address referred by user program; address used in binary codes. physical address Space MMU Physical Memory logical address space logical address CPU physical address 0346: logical address User Program Jump 0346 14346 14398 2

Address binding Address binding: binding the logical memory addresses in instructions and data to physical memory addresses.! In source programs: symbolic addresses (e.g., count, i, j, etc.) A compiler will bind each symbolic address to a relocatable address (e.g. 14 bytes from the beginning of the module) The linkage editor or loader will bind each relocatable address to a logical address (e.g., 4014) In run-time, MMU will bind each logical address to a physical address (e.g., 074014) The final physical address is used to locate memory. Allow a user program to be loaded in any part of the physical memory address binding in run-time completely separate physical address from logical address Memory-Management Unit (MMU) MMU: maps logical address to physical address. The user program deals with logical addresses; it never sees the real physical addresses. A simple MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory. Logical vs. Physical address (2) Separating logical address from physical address: Requires hardware support : MMI does address mapping dynamically. Why separating logical address from physical address? Easier for compiler More benefits to OS memory management Consider two old methods 3

Address Binding: compile-time In compiling, physical address is generated for every instruction. The compiler has to know where the process will reside in memory. The code can not change location in memory unless it is re-compiled. No separation of logical and physical address spaces. Example:.COM format in MS-DOS. Not a choice for a multiprogramming system. Address Binding: load-time The compiler generate re-locatable code. When OS loading code to memory, physical address is generated for every instruction in the program. The process can be loaded into different memory locations. But once loaded, it can not move during execution. Loading a program is slow. Benefits to separate LA from PA Easier for compiler: Generate binary codes in separate logical spaces. All instructions use LA. Maximum flexibility for OS to manage memory: Program loading is fast, just direct copy. The same binary code can be loaded anywhere in memory. A loaded program can be re-located in memory. Need hardware MMU support. 4

Memory Management Approaches Contiguous Memory Allocation Paging Segmentation Segmentation with paging Contiguous Memory Allocation Every process is allocated to a single contiguous section of physical memory. process 4" process 4" process 2" process 5" Memory Management Unit (MMU) Two registers: Limit register: the range of logical address Relocation register: ing position of physical memory In context switch, the dispatcher load both registers with correct values. Every memory access is checked by MMU hardware as: MMU 5

Free Memory Management OS must keep the information on which parts of memory are available and which are occupied. allocated partitions free partitions (holes) Hole: a block of free memory. holes of various are scattered throughout memory When a process arrives, it is allocated memory from a hole large enough to accommodate it. Use linked lists: Free Memory Dynamic Storage-Allocation Problem How to satisfy a request of n from a list of free holes that have various.! First-fit: Allocate the first hole that is big enough. Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by. Produces the smallest leftover hole. Worst-fit: Allocate the largest hole; must also search entire list. Produces the largest leftover hole. 1. First-fit and best-fit are better than worst-fit in terms of speed and memory utilization.! 2. First-fit is faster than best-fit.! Contiguous Memory Allocation: External Fragmentation External fragmentation total memory space exists to satisfy a request, but it is not contiguous. Contiguous memory allocation suffers serious external fragmentation; Free memory is quickly broken into little pieces. 50-percent rule for first fit (1/3 is wasted). Reduce external fragmentation by compaction: Shuffle memory contents to place all free memory together in one large block. Compaction is possible only if relocation is dynamic, and is done at execution time. Compaction is very costly. Reduce external fragmentation by better memory management methods: Paging. Segmentation. 6

Contiguous Memory Allocation: Expanding memory How to allocate more memory to an existing process? Move-and-Copy may be needed. It is difficult to share memory among different processes. 7