Requirements, Partitioning, paging, and segmentation

Similar documents
Requirements, Partitioning, paging, and segmentation

Memory Management. Memory Management

Memory Management. Memory Management Requirements

Memory Management william stallings, maurizio pizzonia - sistemi operativi

Paging, and segmentation

3. Memory Management

Lecture 7. Memory Management

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

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

Chapter 7 Memory Management

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

CIS Operating Systems Memory Management. Professor Qiang Zeng Fall 2017

CSCI 4500 / 8506 Sample Questions for Quiz 5

UNIT III MEMORY MANAGEMENT

Process. Memory Management

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

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

Memory Management. Memory Management

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

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

Chapter 9 Real Memory Organization and Management

Chapter 9 Real Memory Organization and Management

COMPUTER SCIENCE 4500 OPERATING SYSTEMS

Preview. Memory Management

ECE 598 Advanced Operating Systems Lecture 10

Memory management. Knut Omang Ifi/Oracle 10 Oct, 2012

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

CS Operating Systems

CS Operating Systems

12: Memory Management

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

8: Memory Management

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

Memory Management Basics

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

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

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

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

Administrivia. Deadlock Prevention Techniques. Handling Deadlock. Deadlock Avoidance

MEMORY MANAGEMENT/1 CS 409, FALL 2013

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

The Memory Management Unit. Operating Systems. Autumn CS4023

Operating Systems (2INC0) 2017/18

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

CS420: Operating Systems

In multiprogramming systems, processes share a common store. Processes need space for:

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

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

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

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

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

Memory Management. Dr. Yingwu Zhu

Operating Systems Unit 6. Memory Management

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

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

Memory Management. Memory Management. G53OPS: Operating Systems. Memory Management Monoprogramming 11/27/2008. Graham Kendall.

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

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

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

Chapter 8: Memory Management

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

CS399 New Beginnings. Jonathan Walpole

MEMORY MANAGEMENT: Real Storage. Unit IV

Memory Management. COMP755 Advanced Operating Systems

Introduction to Operating Systems

Memory Allocation. Static Allocation. Dynamic Allocation. Dynamic Storage Allocation. CS 414: Operating Systems Spring 2008

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

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

Memory management: outline

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

Memory management: outline

Virtual Memory. 11/8/16 (election day) Vote!

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

Motivation. Memory Management. Memory Management. Computer Hardware Review

Main Memory (Part I)

Optimizing Dynamic Memory Management

RAM, Design Space, Examples. January Winter Term 2008/09 Gerd Liefländer Universität Karlsruhe (TH), System Architecture Group

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

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

Classifying Information Stored in Memory! Memory Management in a Uniprogrammed System! Segments of a Process! Processing a User Program!

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

Chapter 4: Memory Management. Part 1: Mechanisms for Managing Memory

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

Chapter 8. Operating System Support. Yonsei University

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru Department of Electronics and Communication Engineering

Last class: Today: Deadlocks. Memory Management

ECE 598 Advanced Operating Systems Lecture 12

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

Memory Management. Jo, Heeseung

CSCI 4717 Computer Architecture. Memory Management. What is Swapping? Swapping. Partitioning. Fixed-Sized Partitions (continued)

Background. Contiguous Memory Allocation

MEMORY MANAGEMENT. Jo, Heeseung

Dynamic Memory Management

Outlook. File-System Interface Allocation-Methods Free Space Management

Segmentation. Multiple Segments. Lecture Notes Week 6

! What is main memory? ! What is static and dynamic allocation? ! What is segmentation? Maria Hybinette, UGA. High Address (0x7fffffff) !

Operating Systems, Fall

Operating Systems, Fall

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

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

Transcription:

Requirements, Partitioning, paging, and segmentation

Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as many processes into memory as possible Q1 2

Big Picture kernel memory proc struct kernel stack/u area Stack kernel stack/u area Stack kernel stack/u area Stack Data Text (shared) Data Text (shared) Data Text (shared) 3

Memory mgnt requirements Relocation Protection Sharing Logical organization Physical organization Q2 4

Relocation Why/What: Programmer does not know where the program will be placed in memory when it is executed While the program is executing, it may be swapped to disk and returned to main memory at a different location Consequences/Constraints: Memory references must be translated in the code to actual physical memory address 5

Protection Protection and Relocation are interrelated Why/What: Protect process from interference by other processes Processes require permission to access memory in another processes address space. Consequences/Constraints: Impossible to check addresses in programs since the program could be relocated Must be checked at run time 6

Sharing Sharing and Relocation are interrelated Allow several processes to access the same data Allow multiple process to share the same program text rather than have their own separate copy 7

Logical Organization Programs organized into modules stack, text, uninitialized data, or logical modules such as libraries, objects, etc. Code modules may be compiled independently Different degrees of protection given to modules read only, execute only Share modules 8

Unix Process Memory Layout Low Address Text Initialized Data Uninitialized Data (BSS) Heap Read from program file by exec Zeroed by exec Stack High Address argv[ ], env[ ] Q3 9

Physical Organization Memory organized into two levels: main and secondary memory. Memory available for a program plus its data may be insufficient Overlaying allows various modules to be assigned the same region of memory Main memory relatively fast, expensive and volatile Secondary memory relatively slow, cheaper, larger capacity, and non volatile Q410

Hardware support for memory mgnt How to partition memory How to keep track of which partition belongs to which process How to prevent a process from accessing a partition that has not been allocated to it 11

Memory Partitioning Virtual Memory Segmentation and/or Paging Non Virtual memory approaches Partitioning Fixed and Dynamic Simple Paging Simple Segmentation 12

Fixed Partitioning Partition available memory into regions with fixed boundaries Equal size partitions Process whose size <= partition size can be loaded into available partition If all partitions are full, the operating system can swap a process out of a partition If program size > partition size, then programmer must use overlays 13

Fixed Partitioning Equal Size Main memory use is inefficient Internal Fragmentation Part of partition unused Operating System 8 M process 1 Unused 8 M 8 M 3 M 8 M 14

Fixed partitioning unequal sizes Lessons the problem of Internal Fragmentation Operating System 2 M process 1 6 M 8 M 3 M 8 M 12 M 15

Fixed partition: placement algorithm Equal size partitions because all partitions are of equal size, it does not matter which partition is used Unequal size partitions can assign each process to the smallest partition within which it will fit queue for each partition processes are assigned in such a way as to minimize wasted memory within a partition 16

One Process Queue per partition Operating System New Processes 17

One Process Queue for all partitions Operating System New Processes 18

Pros and cons of fixed partitioning Pros: Fixed partitioning is simple and very little OS support is required. Cons: Since number of partitions is fixed, it limits the degree of multi programming It is inefficient with small processes. If the sizes of processes is known beforehand then a reasonable size can be decided on. 19

Dynamic Partitioning Partitions are created dynamically Partitions are of variable length and number Process is allocated exactly as much memory as required Disadvantages: External Fragmentation small holes in memory between allocated partitions Placement is more complicated Must use compaction to shift processes so they are contiguous and all free memory is in one block Q5, 6 20

Example Dynamic Partitioning 21

Dynamic partition: placement alg. Operating system must decide which free block to allocate to a process Best fit algorithm Chooses block that is closest in size to the request Results in minimally sized fragments requiring compaction Worst performer overall 22

Dynamic partition: placement alg. First fit algorithm Starts scanning from beginning and choose first available block that is large enough. May have many process loaded in the front end of memory Fastest Best 23

Dynamic partition: placement alg. Next fit Scan memory from the location of the last allocation and chooses the next available block that is large enough More often allocate a block of memory at the end of memory where the largest block is found Compaction is required to obtain a large block at the end of memory Compaction is more frequent 24

8K alloc 16K block 8K 12K First Fit 12K Last allocated block (14K) 22K 18K Best Fit 6K 2K 8K 6K 8K 6K Allocated block 14K Free block Next Fit 14K 36K Before 20K After Q7 25

Buddy System Fixed and dynamic partitioning have their drawbacks Fixed partitioning Limits number of active processes Uses space inefficiently if the sizes of the processes don t match with that of the partitions Dynamic partitioning More complex to maintain Includes overhead of compaction 26

Buddy System Entire space available is treated as a single block of size 2 U If a request for a block of size s such that 2 U 1 < s <= 2 U Allocated entire block Otherwise Split block into two equal buddies Continues until smallest block greater than or equal to s becomes available requests rounded to power of two Q827

Buddy System Advantages: coalesces adjacent blocks Disadvantage: performance (recursive coalescing is expensive) poor api 28

Buddy System Allocation Begin with one large block Suppose we want a block of size 16 256 128 64 32 16 8 4 2 1 29

Buddy System Allocation Begin with one large block Recursively subdivide 256 128 64 32 16 8 4 2 1 30

Buddy System Allocation Begin with one large block Recursively subdivide 256 128 64 32 16 8 4 2 1 31

Buddy System Allocation Begin with one large block Recursively subdivide 256 128 64 32 16 8 4 2 1 32

Buddy System Allocation Begin with one large block Yield 2 blocks size 16 256 128 64 32 16 8 4 2 1 33

Buddy System Allocation Begin with one large block Yield 2 blocks size 16 One of those blocks can be given to the program 256 128 64 32 16 8 4 2 1 34

Deallocation and Coalescing 256 128 64 32 16 8 4 2 1 35

Deallocation and Coalescing When a block becomes free, it tries to rejoin its buddy 256 128 64 32 A bit in its buddy tells whether the buddy is free 16 8 4 2 If so, they can glue together and make a block twice as big 1 Q9 36

Deallocation and Coalescing 256 128 64 32 16 8 4 2 1 37

Deallocation and Coalescing 256 128 64 32 16 8 4 2 1 38

Deallocation and Coalescing 256 128 64 32 16 8 4 2 1 39

Deallocation and Coalescing Coalescing strategies: Prompt at the point of deallocation (right away) Delayed wait until it s necessary (at allocation) Thorough coalesce the entire heap Demand coalesce only to satisfy an allocation request 256 128 64 32 16 8 4 2 1 40