Memory ManagementCS-502 Fall 20061 Memory Management CS-502 Operating Systems Fall 2006 (Slides include materials from Operating System Concepts, 7 th.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Part IV: Memory Management
CSS430 Memory Management Textbook Ch8
CS 153 Design of Operating Systems Spring 2015
Memory Management Design & Implementation Segmentation Chapter 4.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
Memory Management.
Chapter 8 Operating System Support
Memory Management (continued) CS-3013 C-term Memory Management CS-3013 Operating Systems C-term 2008 (Slides include materials from Operating System.
Memory ManagementCS-3013 A-term Memory Management CS-3013, Operating Systems A-term 2009 (Slides include materials from Modern Operating Systems,
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 Management Chapter 5.
Computer Organization and Architecture
Memory ManagementCS-3013 C-term Memory Management CS-3013 Operating Systems C-term 2008 (Slides include materials from Operating System Concepts,
Main Memory. Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Memory Management CSE451 Andrew Whitaker. Big Picture Up till now, we’ve focused on how multiple programs share the CPU Now: how do multiple programs.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
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.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
1 Address Translation Memory Allocation –Linked lists –Bit maps Options for managing memory –Base and Bound –Segmentation –Paging Paged page tables Inverted.
CE Operating Systems Lecture 14 Memory management.
Chapter 4 Memory Management Virtual Memory.
Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
1 Memory Management Basics. 2 Program P Basic Memory Management Concepts Address spaces Physical address space — The address space supported by the hardware.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
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.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
1 Memory Management n In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes.
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 2 Memory and process management
Chapter 8: Main Memory.
Main Memory Management
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
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-I 1.
Main Memory Background Swapping Contiguous Allocation Paging
Introduction to Memory Management
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.
Lecture 3: Main Memory.
CSE 451: Operating Systems Autumn 2005 Memory Management
Operating System Chapter 7. Memory Management
Chapter 8: Memory Management strategies
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
COMP755 Advanced Operating Systems
Presentation transcript:

Memory ManagementCS-502 Fall Memory Management CS-502 Operating Systems Fall 2006 (Slides include materials from Operating System Concepts, 7 th ed., by Silbershatz, Galvin, & Gagne and from Modern Operating Systems, 2 nd ed., by Tanenbaum)

Memory ManagementCS-502 Fall In the Beginning (prehistory)… Batch systems –One program loaded in physical memory at a time –Runs to completion If job larger than physical memory, use overlays –Identify sections of program that Can run to a result Can fit into the available memory –Add statement after result to load a new section –Example: passes of a compiler –Example: SAGE – North American Air Defense System

Memory ManagementCS-502 Fall Still near the Beginning (multi-tasking) … Multiple processes in physical memory at the same time –allows fast switching to a ready process –Divide physical memory into multiple pieces – partitioning –Some modern real-time operating systems Partition requirements –Protection – keep processes from smashing each other –Fast execution – memory accesses can’t be slowed by protection mechanisms –Fast context switch – can’t take forever to setup mapping of addresses

Memory ManagementCS-502 Fall Physical Memory 0x x0000FFFF Physical address space OS Kernel Process 1 Process 2 Empty Process 3 E.g, OS360

Memory ManagementCS-502 Fall Loading a Process Relocate all addresses relative to start of partition –See Linking and Loading Memory protection assigned by OS –Block-by-block to physical memory –Base and limit registers Once process starts –Partition cannot be moved in memory –Why?

Memory ManagementCS-502 Fall Physical Memory – Process 2 terminates 0x x0001FFFF Physical address space OS Kernel Process 1 Empty Process 3

Memory ManagementCS-502 Fall Problem What happens when Process 4 comes along and requires space larger than the largest empty partition? Wait Complex resource allocation problem for OS Potential starvation

Memory ManagementCS-502 Fall Physical Memory OS Kernel Process 1 Empty Process 3 Process 4

Memory ManagementCS-502 Fall Solution Virtual Address: an address used by the program that is translated by computer into a physical address each time it is used Also called Logical Address When the program utters 0x00105C, … … the machine accesses 0x01605C

Memory ManagementCS-502 Fall Implementation Base and Limit registers –Base automatically added to all addresses –Limit checked on all memory references –Introduced in minicomputers of early 1970s Loaded by OS at each context switch logical address Limit Reg < error no Reloc Reg + yes physical address Physical Memory CPU

Memory ManagementCS-502 Fall Physical Memory 0x x0003FFFF Physical address space OS Kernel Process 1 Empty Process 3 Base Limit

Memory ManagementCS-502 Fall Advantages No relocation of program addresses at load time All addresses relative to zero! Built-in protection provided by Limit No physical protection per page or block Fast execution Addition and limit check at hardware speeds within each instruction Fast context switch Need only change base and limit registers Partition can be suspended and moved at any time Process is unaware of change Potentially expensive for large processes due to copy costs!

Memory ManagementCS-502 Fall Physical Memory 0x x0003FFFF Physical address space OS Kernel Process 1 Process 3 Base Limit Process 4

Memory ManagementCS-502 Fall Definition Virtual Address Space: –The address space in which a process or thread “thinks” –Address space with respect to which pointers, code & data addresses, etc., are interpreted –Separate and independent of physical address space where things are actually stored

Memory ManagementCS-502 Fall Challenge – Memory Allocation Fixed partitions Variable partitions

Memory ManagementCS-502 Fall Partitioning Strategies – Fixed Fixed Partitions – divide memory into equal sized pieces (except for OS) –Degree of multiprogramming = number of partitions –Simple policy to implement All processes must fit into partition space Find any free partition and load the process Problem – what is the “right” partition size? –Process size is limited –Internal Fragmentation – unused memory in a partition that is not available to other processes

Memory ManagementCS-502 Fall Partitioning Strategies – Variable Idea: remove “wasted” memory that is not needed in each partition Eliminating internal fragmentation Memory is dynamically divided into partitions based on process needs Definition: –Hole: a block of free or available memory –Holes are scattered throughout physical memory New process is allocated memory from hole large enough to fit it

Memory ManagementCS-502 Fall Variable Partitions More complex management problem  Must track free and used memory  Need data structures to do tracking  What holes are used for a process?  External fragmentation  memory that is outside any partition and is too small to be usable by any process OS process 1 process 2 process 3 OS process 1 process 3 Process 2 Terminates OS process 1 process 3 Process 4 Starts process 4

Memory ManagementCS-502 Fall Memory Allocation – Mechanism MM system maintains data about free and allocated memory alternatives –Bit maps – 1 bit per “allocation unit” –Linked Lists – free list updated and coalesced when not allocated to a process At swap-in or process create –Find free memory that is large enough to hold the process –Allocate part (or all) of memory to process and mark remainder as free Compaction –Moving things around so that holes can be consolidated –Expensive in OS time

Memory ManagementCS-502 Fall Memory Management - Maps Part of memory with 5 processes, 3 holes –tick marks show allocation units –shaded regions are free Corresponding bit map Same information as a list

Memory ManagementCS-502 Fall Memory Management – Policies Policy examples –First Fit: scan free list and allocate first hole that is large enough – fast –Next Fit: start search from end of last allocation –Best Fit: find smallest hole that is adequate – slower and lots of fragmentation –Worst fit: find largest hole –In general, First Fit is the winner

Memory ManagementCS-502 Fall Swapping and Scheduling Swapping –Move process from memory to disk (swap space) Process is blocked or suspended –Move process from swap space to big enough partition Process is ready Set up Base and Limit registers –Memory Manager (MM) and Process scheduler work together Scheduler keeps track of all processes MM keeps track of memory Scheduler marks processes as swap-able and notifies MM to swap in processes Scheduler policy must account for swapping overhead MM policy must account for need to have memory space for ready processes More in Chapter 8 of Silbershatz

Memory ManagementCS-502 Fall Can we do better?

Memory ManagementCS-502 Fall User’s View of a Program

Memory ManagementCS-502 Fall Memory Management – beyond Partitions Can we improve memory utilization & performance –Processes have distinct parts Code – program and maybe shared libraries Data – pre-allocated and heap Stack –Solution – slightly more Memory Management hardware Multiple sets of “base and limit” registers Divide process into logical pieces called segments Advantages of segments –Code segments don’t need to be swapped out and may be shared –Stack and heap can be grown – may require segment swap –With separate I and D spaces can have larger virtual address spaces “I” = Instruction (i.e., code, always read-only) “D” = Data (usually read-write)

Memory ManagementCS-502 Fall Logical View of Segmentation user spacephysical memory space

Memory ManagementCS-502 Fall Segmentation Logical address consists of a pair: Segment table – maps two-dimensional physical addresses; each table entry has: –Base: contains the starting physical address where the segments reside in memory. –Limit: specifies the length of the segment.

Memory ManagementCS-502 Fall Segment Lookup segment 0 segment 1 segment 2 segment 3 segment 4 physical memory segment # + virtual address <? raise protection fault no yes offset baselimit Segment register table Index to segment register table Physical Address

Memory ManagementCS-502 Fall Segmentation Protection. With each entry in segment table associate: –validation bit = 0  illegal segment –read/write/execute privileges Protection bits associated with segments; code sharing occurs at segment level. Since segments vary in length, memory allocation is a dynamic storage-allocation problem

Memory ManagementCS-502 Fall Segmentation Common in early minicomputers –Small amount of additional hardware – 4 or 8 segments –Used effectively in classical Unix Good idea that has persisted and supported in current hardware and OSs –X86 supports segments –Linux supports segments Still have external fragmentation of memory What is the next level of Memory Management improvement? –Next topic

Memory ManagementCS-502 Fall Questions Next Topic