Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Fixed/Variable Partitioning
Allocating Memory.
CS 311 – Lecture 21 Outline Memory management in UNIX
1 CSE 380 Computer Operating Systems Instructor: Insup Lee University of Pennsylvania, Fall 2002 Lecture Note: Memory Management.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
CS 104 Introduction to Computer Science and Graphics Problems
Memory Management.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Chapter 8 Operating System Support
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Memory ManagementCS-502 Fall Memory Management CS-502 Operating Systems Fall 2006 (Slides include materials from Operating System Concepts, 7 th.
Memory Management Chapter 5.
Computer Organization and Architecture
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.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
CS364 CH08 Operating System Support TECH Computer Science Operating System Overview Scheduling Memory Management Pentium II and PowerPC Memory Management.
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 32 Paging Read Ch. 9.4.
Review of Memory Management, Virtual Memory CS448.
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.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally MEMORYMANAGEMNT.
Dynamic Partition Allocation Allocate memory depending on requirements Partitions adjust depending on memory size Requires relocatable code –Works best.
8.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 8: Memory-Management Strategies Objectives To provide a detailed description.
Chapter 5 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
1 Memory Management Chapter Basic memory management 4.2 Swapping (εναλλαγή) 4.3 Virtual memory (εικονική/ιδεατή μνήμη) 4.4 Page replacement algorithms.
Chapter 4 Memory Management.
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
Chapter 2 Memory Management: Early Systems Understanding Operating Systems, Fourth Edition.
Memory Management 1 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
1 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
Subject: Operating System.
Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
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.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Basic Memory Management 1. Readings r Silbershatz et al: chapters
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Mono an multiprogramming.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo 1 Memory management & paging.
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
CHAPTER 3-1, 3-2 MEMORY MANAGEMENT. MEMORY HIERARCHY Small amount of expensive, fast, volatile cache Larger amount of still fast, but slower, volatile.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
Main Memory CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
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 One of the most important OS jobs.
Chapter 2 Memory and process management
From Monoprogramming to multiprogramming with swapping
Memory Allocation The main memory must accommodate both:
William Stallings Computer Organization and Architecture
Main Memory Management
Module IV Memory Organization.
Multistep Processing of a User Program
So far… Text RO …. printf() RW link printf Linking, loading
Main Memory Background Swapping Contiguous Allocation Paging
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Memory Management (1).
Page Main Memory.
Presentation transcript:

Memory Management Chapter 4

Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:

Memory manager Tracks which parts of memory are in use Allocates memory to processes –Long-term scheduling De-allocates memory from processes Swaps between main memory and disk when main memory is too small to hold all of the processes –Intermediate scheduling

Simple memory management An operating system with one user process

Multiprogramming Use fixed-sized partitions (MFT) –Each partition contained only one process –Very simple More flexibility is achieved with MVT –OS knows which parts of memory are available –When a process is to be loaded, it needs a large enough block of contiguous memory

Multiprogramming with fixed size partitions (MFT) single input queue for all memory separate input queue for each partition

MVT Example job queue at time 0 operating system 0 400K 2160K 2560K How to schedule the job queue in a FCFS fashion? process memory time in system P1 600K10 P2 1000K 5 P3 300K20 P4 700K 8 P5 500K15

MVT Example – at time 5 job queue process memory time in system P4 700K 8 P5 500K15 operating system 0 400K 260K 2560K Now P2 is done, so replace with P4… P1 P2 P3 2000K 2300K 1000 K

MVT Example – at time 8 job queue process memory time in system P5 500K15 operating system 0 400K 260K 2560K Now P4 is done, so replace with P5… P1 P4 P3 2000K 2300K 1000 K 1700 K 300K

MVT Example – at time 8+ Empty job queue operating system 0 400K 260K 2560K This worked well with our configuration of jobs, but what can go wrong? P1 P5 P3 2000K 2300K 1000 K 1500 K 500K

CPU utilization as a function of number of processes in memory Degree of multiprogramming

Relocatability Processes are loaded into main memory –They may be loaded into any unoccupied user space. –Successive executions of the same process may be loaded into different main memory locations. This is the concept of relocatability –Any memory address references within a process (i.e., variables, instructions) are relative

Address mapping CPUmemory logical address 346 physical address MMU relocatio n register

Protecting processes from each other Use base and limit values –Each location within a process is added to base value to map it to a physical address –Any address locations larger than the limit value are flagged as errors

Base-limit registers One base-limit pair and two base-limit pairs

Swapping What to do if there is not enough memory to store all active processes? –Swap certain processes out and then back in An executing process must be in main memory, but can be temporarily swapped out & then back into memory –Consider a preemptive CPU scheduling algorithm such as RR

About swapping... When the CPU is ready for the next process, it selects it from the ready queue. –If it has been swapped out, the memory manager brings it back in. –If there is no room for it, another process is swapped out first. –Context-switch time is high. If a process is to be swapped out of main memory, it must be completely idle –If it is waiting for I/O, then another candidate is found, if possible

Swapping entire processes Swapping can create holes or fragments in memory

Fragmentation As processes are loaded and removed from memory, available memory space is broken into pieces When there is enough memory space to satisfy a request, but it is not contiguous, we say there is external fragmentation When there is wasted space within a process’ address space, we have internal fragmentation (later on this)

Compaction A solution to external fragmentation. Partitions are rearranged to collect all the fragments into one large block. –Requires all internal addresses to be remapped to new physical addresses –All partitions are moved to one end of memory and all base and limit registers are altered. Very costly

Swapping with room for growth Space for growing data segment Space for growing data & stack segments

Implementation How is dynamic memory allocation actually implemented? Two approaches –Using bitmaps –Using linked lists Strategies for assignment of processes to memory spaces

Using bit maps Part of memory with 5 processes, 3 holes –tick marks show allocation units – may be a few words up to several KB –shaded regions are free –Searching bitmaps can be slow

Using linked lists Part of memory with 5 processes, 3 holes This example uses a singly linked list – a doubly linked list would make it easier to merge available slots See next slide We have several strategies for assigning memory

Memory management with linked lists Four neighbor combinations for the terminating process X

Allocation strategies First-fit: Starting at the head of the list, allocate the first hole that is found to be big enough. –Next fit: pick up where it left the list last time Best-fit: Search entire list to find the optimal fit. –this allocates the smallest hole that is big enough. Worst-fit: Search entire list to find the largest available hole. Quick fit: Uses separate lists for more common process sizes

Assignment In-class: –p #5 HW: –Given memory partitions of 100K, 500K, 200K, 300K, 600K (in order), how would each of first-fit, best-fit, worst-fit, and next-fit algorithms place processes of 212K, 417K, 112K, 426K (in this order)? –Read Sections 4.3 & 4.4