CIS Operating Systems Contiguous Memory Allocation. Professor Qiang Zeng Spring 2018

Similar documents
CIS Operating Systems Memory Management. Professor Qiang Zeng Fall 2017

CIS Operating Systems Non-contiguous Memory Allocation. Professor Qiang Zeng Spring 2018

CSCE Operating Systems Non-contiguous Memory Allocation. Qiang Zeng, Ph.D. Fall 2018

Memory Management. Memory Management

Memory Management. Memory Management Requirements

Requirements, Partitioning, paging, and segmentation

Memory Management william stallings, maurizio pizzonia - sistemi operativi

Chapter 7 Memory Management

Requirements, Partitioning, paging, and segmentation

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

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

The Memory Management Unit. Operating Systems. Autumn CS4023

CSCI 4500 / 8506 Sample Questions for Quiz 5

Preview. Memory Management

UNIT III MEMORY MANAGEMENT

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

Lecture 7. Memory Management

3. Memory Management

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

Heap Management portion of the store lives indefinitely until the program explicitly deletes it C++ and Java new Such objects are stored on a heap

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

MEMORY MANAGEMENT/1 CS 409, FALL 2013

Operating Systems Unit 6. Memory Management

CIS Operating Systems Memory Management Address Translation. Professor Qiang Zeng Fall 2017

CSCE Operating Systems Scheduling. Qiang Zeng, Ph.D. Fall 2018

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

Memory Management. Memory Management

Process. Memory Management

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

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

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

Part II: Memory Management. Chapter 7: Physical Memory Chapter 8: Virtual Memory Chapter 9: Sharing Data and Code in Main Memory

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

Memory Management. COMP755 Advanced Operating Systems

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

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

CS370 Operating Systems

Administrivia. Deadlock Prevention Techniques. Handling Deadlock. Deadlock Avoidance

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

CS420: Operating Systems

Memory Management Basics

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

ECE 598 Advanced Operating Systems Lecture 10

Chapter 9 Real Memory Organization and Management

Chapter 9 Real Memory Organization and Management

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

COMPUTER SCIENCE 4500 OPERATING SYSTEMS

CS Operating Systems

CS Operating Systems

Processes, Address Spaces, and Memory Management. CS449 Spring 2016

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

Memory: Overview. CS439: Principles of Computer Systems February 26, 2018

Background. Contiguous Memory Allocation

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

Frequently asked questions from the previous class survey

Memory Management. Jo, Heeseung

Events, Memory Management

Operating Systems (2INC0) 2017/18

8: Memory Management

MEMORY MANAGEMENT: Real Storage. Unit IV

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

12: Memory Management

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

Chapter 8: Memory Management

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

Memory management: outline

Objectives and Functions Convenience. William Stallings Computer Organization and Architecture 7 th Edition. Efficiency

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

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

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

Operating System Support

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

FILE SYSTEM IMPLEMENTATION. Sunu Wibirama

Chapter 5: CPU Scheduling

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Chapter 3 - Memory Management

MEMORY MANAGEMENT. Jo, Heeseung

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

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

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

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

20-EECE-4029 Operating Systems Spring, 2013 John Franco

Module 8: Memory Management

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

Chapter 8: Main Memory

Memory management: outline

Memory Management III Memory Alloca0on

Chapter 9: Memory Management. Background

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

Memory Management. Dr. Yingwu Zhu

Chapter 8: Main Memory

Operating Systems. Instructor: Dmitri A. Gusev. Spring Lecture 16, April 17, CSC : Introduction to Computer Science

Memory Management. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

Run-time Environments -Part 3

Main Memory (Part I)

Chapter 10: Case Studies. So what happens in a real operating system?

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

CS 111. Operating Systems Peter Reiher

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 13: Address Translation

Transcription:

CIS 3207 - Operating Systems Contiguous Memory Allocation Professor Qiang Zeng Spring 2018

Previous class Uniprocessor policies FCFS, Shortest Job First Round Robin Multilevel Feedback Queue Multiprocessor policies A MFQ per processor A process has affinity with a processor Exception: idle cores can steal processes CIS 3207 - Operating Systems 2

Background Main memory and registers are the only storage that a CPU can access directly Program must be brought (from disk) into memory for it to be run CIS 3207 - Operating Systems 3

Outline Fixed partitions Dynamic partitions Buddy system Contiguous allocation: Each process occupies a contiguous memory region in the physical memory Segmentation Paging Non-contiguous allocation: Each process occupies multiple memory regions scattered in the physical memory. CIS 3207 - Operating Systems 4

Fixed partitions The bounds of each partition are fixed/ predefined Disadvantages: Cause Internal Fragmentation when the allocated space is larger than the need What is fragmentation? Small useless chunks E.g., when you put a 13M process in the 16M partition, 3M space is wasted and it is called internal fragmentation Internal: the wasted space is inside allocated space The number of active processes is limited Analogy: street parking with meters CIS 3207 - Operating Systems 5

Fixed partitions - questions If 8M partitions are all used, where do you place a 7M process, and what is the size of the internal fragmentation? The 12M partition is the best choice The internal fragmentation is 5M How to resolve the severe internal fragmentation? Dynamic partitions CIS 3207 - Operating Systems 6

Dynamic partitions Process is allocated exactly the memory it requires The partitions are dynamic: the number and locations of partitions are not fixed Analogy: street parking without meters CIS 3207 - Operating Systems 7

Dynamic partitions - example CIS 3207 - Operating Systems 8

Dynamic partition - disadvantage External fragmentation Their total size is large enough to satisfy a request, but they are not contiguous, so cannot be used to service the request External: fragmentation is outside allocated space Solution: Compaction OS shifts processes so that they are contiguous; thus, free memory is together in one block But, program execution must be paused for relocation; waste CPU time CIS 3207 - Operating Systems 9

Placement Algorithms When there is more than one free block of memory of sufficient size, the system must decide which free block to allocate. Best-fit chooses the block that is closest in size to the request First-fit scan memory from the beginning and chooses the first available block that is large enough Next-fit scan memory from the location of the last placement and chooses the next available block that is large enough CIS 3207 - Operating Systems 10

Placement Algorithms - Example CIS 3207 - Operating Systems 11 Assume a 16M partition is requested

Questions Does Fixed Partitions Allocation have external fragmentation? Zero There are no small useless chunks Does Dynamic Partitions Allocation have internal fragmentation? Zero The allocated partition size is as needed CIS 3207 - Operating Systems 12

Buddy System (or, Buddy Memory Management) Fixed partitions cause zero external fragmentation but severe internal fragmentation, while dynamic partitions cause zero internal fragmentation but severe external fragmentation Buddy System is between the two It causes acceptable internal and external fragmentation, and has good overall performance Three properties Split-based allocation Freelists-based implementation Coalescing-buddy-based deallocation CIS 3207 - Operating Systems 13

Buddy System allocate the first block To begin, the entire space available for allocation is treated as a single block of size 2 U The request size is first rounded up as power of 2, denoted as S E.g., 55 -> 2 6 =64; 120 -> 2 7 =128 If S = 2 U, then the entire block is allocated. Otherwise, the block is split into two equal buddies of size 2 U-1 If S = 2 U-1, then the request is allocated to one of the two buddies. Otherwise, one of the buddies is split into halves again. This process continues until the split block is equal to S and it is allocated to the request CIS 3207 - Operating Systems 14

Buddy System split-based allocation CIS 3207 - Operating Systems 15

A Binary Tree Representation Buddies: sibling nodes, i.e., two nodes that share the parent node in the binary tree representation CIS 3207 - Operating Systems 16

Buddy System free-lists-based implementation A free list is a linked list data structure used to connect all unallocated storage chunks. It is quick and easy to allocate and unallocate a storage chunk Order 0: 2 0 x 64k = 64k 1: 2 1 x 64k = 128k 2: 2 2 x 64k = 256k 3: 2 3 x 64k = 512k 4: 2 4 x 64k = 1024k One 2 2 block is allocated CIS 3207 - Operating Systems 17

Buddy System used In Linux The Buddy System is used in Linux (and many other OSes) to manage the physical memory CIS 3207 - Operating Systems 18

Buddy System coalescing-buddy-based deallocation Whenever a block is freed, it tries to coalesce with its buddy. The coalescing procedure is recursive CIS 3207 - Operating Systems 19

Buddy System - fragmentation Internal fragmentation? Worst case ~ 50% E.g., request 128.01K, which is rounded up to 128x2K External fragmentation Still exists, as coalescing can only occur between buddies Best-fit is always used: freelists-based implementation allows you to find the best-fit chunk quickly By applying restriction on splitting, you will not see small mini tiny useless holes; e.g., previously we limit the smallest block as 64k CIS 3207 - Operating Systems 20

Big picture Fixed partitions Dynamic partitions Buddy system Contiguous allocation: Each process occupies a contiguous memory region in the physical memory Segmentation Paging Non-contiguous allocation: Each process comprises multiple memory regions scattered in the physical memory. CIS 3207 - Operating Systems 21