Chapter 2 Memory Management: Early Systems Understanding Operating Systems, Fourth Edition.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Memory management In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. Memory management is achieved.
Chapter 6: Memory Management
Chapter 2: Memory Management, Early Systems
Chapter 2: Memory Management, Early Systems
Memory Management, Early Systems
Understanding Operating Systems Fifth Edition
Memory Management Chapter 7.
Fixed/Variable Partitioning
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable supply of ready processes to.
Allocating Memory.
Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2009, Prentice.
CS 311 – Lecture 21 Outline Memory management in UNIX
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
CS 104 Introduction to Computer Science and Graphics Problems
Memory Management Chapter 7 B.Ramamurthy. Memory Management Subdividing memory to accommodate multiple processes Memory needs to allocated efficiently.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
1 Friday, June 30, 2006 "Man's mind, once stretched by a new idea, never regains its original dimensions." - Oliver Wendell Holmes, Jr.
Memory Management Chapter 5.
Silberschatz, Galvin and Gagne  Operating System Concepts Multistep Processing of a User Program User programs go through several steps before.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 9 – Real Memory Organization and Management Outline 9.1 Introduction 9.2Memory Organization.
Understanding Operating Systems Sixth Edition
Chapter 2 Memory Management: Early Systems (all ancient history)
1 Lecture 8: Memory Mangement Operating System I Spring 2008.
Memory management. Instruction execution cycle Fetch instruction from main memory Decode instruction Fetch operands (if needed0 Execute instruction Store.
Chapter 3 Memory Management: Virtual Memory
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 32 Paging Read Ch. 9.4.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
Swapping and Contiguous Memory Allocation. Multistep Processing of a User Program User programs go through several steps before being run. Program components.
Memory Management Chapter 7.
Memory Management. Process must be loaded into memory before being executed. Memory needs to be allocated to ensure a reasonable supply of ready processes.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Chapter 2 Memory Management: Early Systems Understanding Operating Systems, Fourth Edition.
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
Chapter 2 - Memory Management, Early Systems Ivy Tech State College Northwest Region 01 CIS106 Microcomputer Operating Systems Gina Rue CIS Faculty.
Subject: Operating System.
CE Operating Systems Lecture 14 Memory management.
Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
3.0 : Resource Management Part 1 : Memory Management.
Memory Management. Introduction To improve both the utilization of the CPU and the speed of its response to users, the computer must keep several processes.
Basic Memory Management 1. Readings r Silbershatz et al: chapters
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Memory and Addressing It all starts.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 9 – Real Memory Organization and Management Outline 9.1 Introduction 9.2Memory Organization.
Fall 2000M.B. Ibáñez Lecture 14 Memory Management II Contiguous Allocation.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
MEMORY MANAGEMENT. memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. 
Memory Management Damian Gordon.
Chapter 2 Memory and process management
Day 19 Memory Management.
Memory Allocation The main memory must accommodate both:
Main Memory Management
Module IV Memory Organization.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Multistep Processing of a User Program
Memory management Igor Radovanović.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
So far… Text RO …. printf() RW link printf Linking, loading
Memory Management (1).
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Presentation transcript:

Chapter 2 Memory Management: Early Systems Understanding Operating Systems, Fourth Edition

2 Memory Management: Early Systems Types of memory allocation schemes: –Single-user systems –Fixed partitions –Dynamic partitions –Relocatable dynamic partitions

Understanding Operating Systems, Fourth Edition3 Single-User Contiguous Scheme Single-User Contiguous Scheme: Program is loaded in its entirety into memory and allocated as much contiguous space in memory as it needs –Jobs processed sequentially in single-user systems –Requires minimal work by the Memory Manager Register to store the base address Accumulator to keep track of the program size

Understanding Operating Systems, Fourth Edition4 Single-User Contiguous Scheme (continued) Disadvantages of Single-User Contiguous Scheme: –Doesn’t support multiprogramming –Not cost effective

Understanding Operating Systems, Fourth Edition5 Fixed Partitions Fixed Partitions: Main memory is partitioned; one partition/job –Allows multiprogramming –Partition sizes remain static unless and until computer system id shut down, reconfigured, and restarted –Requires protection of the job’s memory space –Requires matching job size with partition size

Understanding Operating Systems, Fourth Edition6 Fixed Partitions (continued) Table 2.1: A simplified fixed partition memory table with the free partition shaded To allocate memory spaces to jobs, the operating system’s Memory Manager must keep a table as shown below:

Understanding Operating Systems, Fourth Edition7 Fixed Partitions (continued) Figure 2.1: Main memory use during fixed partition allocation of Table 2.1 NOTE: Job 3 must wait even though 70K of free space is available in Partition 1 where Job 1 occupies only 30K of the 100K available

Understanding Operating Systems, Fourth Edition8 Fixed Partitions (continued) Disadvantages: –Requires entire program to be stored contiguously –Jobs are allocated space on the basis of first available partition of required size –Works well only if all of the jobs are of the same size or if the sizes are known ahead of time –Arbitrary partition sizes lead to undesired results Too small a partition size results in large jobs having longer turnaround time Too large a partition size results in memory waste or internal fragmentation

Understanding Operating Systems, Fourth Edition9 Dynamic Partitions Dynamic Partitions: Jobs are given only as much memory as they request when they are loaded –Available memory is kept in contiguous blocks –Memory waste is comparatively small Disadvantages: –Fully utilizes memory only when the first jobs are loaded –Subsequent allocation leads to memory waste or external fragmentation

Understanding Operating Systems, Fourth Edition10 Dynamic Partitions (continued) Figure 2.2: Main memory use during dynamic partition allocation

Understanding Operating Systems, Fourth Edition11 Dynamic Partitions (continued) Figure 2.2 (continued): Main memory use during dynamic partition allocation

Understanding Operating Systems, Fourth Edition12 Best-Fit Versus First-Fit Allocation Free partitions are allocated on the following basis: –First-fit memory allocation: First partition fitting the requirements Leads to fast allocation of memory space –Best-fit memory allocation: Smallest partition fitting the requirements Results in least wasted space Internal fragmentation reduced but not eliminated

Understanding Operating Systems, Fourth Edition13 Best-Fit Versus First-Fit Allocation (continued) First-fit memory allocation: –Advantage: Faster in making allocation –Disadvantage: Leads to memory waste Best-fit memory allocation –Advantage: Makes the best use of memory space –Disadvantage: Slower in making allocation

Understanding Operating Systems, Fourth Edition14 Best-Fit Versus First-Fit Allocation (continued) Figure 2.3: An example of a first-fit free scheme

Understanding Operating Systems, Fourth Edition15 Best-Fit Versus First-Fit Allocation (continued) Figure 2.4: An example of a best-fit free scheme

Understanding Operating Systems, Fourth Edition16 Best-Fit Versus First-Fit Allocation (continued) Algorithm for First-Fit: –Assumes Memory Manager keeps two lists, one for free memory and one for busy memory blocks –Loop compares the size of each job to the size of each memory block until a block is found that’s large enough to fit the job –Job is stored into that block of memory –Memory Manager moves out of the loop to fetch the next job from the entry queue

Understanding Operating Systems, Fourth Edition17 Best-Fit Versus First-Fit Allocation (continued) Algorithm for First-Fit (continued): –If the entire list is searched in vain, then the job is placed into a waiting queue –The Memory Manager then fetches the next job and repeats the process

Understanding Operating Systems, Fourth Edition18 Best-Fit Versus First-Fit Allocation (continued) Table 2.2: Status of each memory block before and after a request is made for a block of 200 spaces using the first-fit algorithm

Understanding Operating Systems, Fourth Edition19 Best-Fit Versus First-Fit Allocation (continued) Algorithm for Best-Fit: –Goal: find the smallest memory block into which the job will fit –Entire table must be searched before allocation

Understanding Operating Systems, Fourth Edition20 Best-Fit Versus First-Fit Allocation (continued) Table 2.3: Status of each memory block before and after a request is made for a memory block of 200 spaces using the best-fit algorithm

Understanding Operating Systems, Fourth Edition21 Best-Fit Versus First-Fit Allocation (continued) Hypothetical allocation schemes: –Next-fit: Starts searching from last allocated block, for the next available block when a new job arrives –Worst-fit: Allocates the largest free available block to the new job Opposite of best-fit Good way to explore the theory of memory allocation; might not be the best choice for an actual system

Understanding Operating Systems, Fourth Edition22 Deallocation Deallocation: Freeing an allocated memory space –For fixed-partition system: Straightforward process When job completes, Memory Manager resets the status of the job’s memory block to “free” Any code—for example, binary values with 0 indicating free and 1 indicating busy—may be used

Understanding Operating Systems, Fourth Edition23 Relocatable Dynamic Partitions Relocatable Dynamic Partitions: –Memory Manager relocates programs to gather together all of the empty blocks –Compact the empty blocks to make one block of memory large enough to accommodate some or all of the jobs waiting to get in

Understanding Operating Systems, Fourth Edition24 Relocatable Dynamic Partitions (continued) Compaction: Reclaiming fragmented sections of the memory space –Every program in memory must be relocated so they are contiguous –Operating system must distinguish between addresses and data values Every address must be adjusted to account for the program’s new location in memory Data values must be left alone

Understanding Operating Systems, Fourth Edition25 Relocatable Dynamic Partitions (continued) Figure 2.7: Three snapshots of memory before and after compaction

Understanding Operating Systems, Fourth Edition26 Relocatable Dynamic Partitions (continued) Compacting and relocating optimizes the use of memory and thus improves throughput Options for when and how often it should be done: –When a certain percentage of memory is busy –When there are jobs waiting to get in –After a prescribed amount of time has elapsed Goal: Optimize processing time and memory use while keeping overhead as low as possible