Memory Management Five Requirements for Memory Management to satisfy: –Relocation Users generally don’t know where they will be placed in main memory May.

Slides:



Advertisements
Similar presentations
Memory Management Chapter 7.
Advertisements

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
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
OS Fall’02 Memory Management Operating Systems Fall 2002.
Chapter 7 Memory Management
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
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.
Memory Management 2010.
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.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Chapter 7 Memory Management
1 Lecture 8: Memory Mangement Operating System I Spring 2008.
1 Memory Management Chapter 7. 2 Roadmap n Memory management u Objectives u Requirements n Simple memory management u Memory partitioning F Fixed partitioning.
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.
Operating System 7 MEMORY MANAGEMENT. MEMORY MANAGEMENT REQUIREMENTS.
Memory Management Chapter 7.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
1 Memory Management (a). 2 Background  Program must be brought into memory and placed within a process for it to be run.  Input queue – collection of.
Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Dr.
Chapter 7 Memory Management
Chapter 7 Memory Management Seventh Edition William Stallings Operating Systems: Internals and Design Principles.
1 Memory Management Chapter Basic memory management 4.2 Swapping (εναλλαγή) 4.3 Virtual memory (εικονική/ιδεατή μνήμη) 4.4 Page replacement algorithms.
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.
Memory Management 1 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
Memory Management Chapter 7.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
Subject: Operating System.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Memory Management Operating Systems CS550. Memory Manager Memory manager - manages allocation and de-allocation of main memory Plays significant impact.
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.
1 Memory Management Chapter 8. 2 Memory Management n It is the task carried out by the OS and hardware to accommodate multiple processes in main memory.
Basic Memory Management 1. Readings r Silbershatz et al: chapters
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
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.
Memory management Ref: Stallings G.Anuradha. What is memory management? The task of subdivision of user portion of memory to accommodate multiple processes.
Memory Management Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only storage.
CSNB224 – AAG 2007 Memory Management Chapter 7. CSNB224 – AAG 2007 Memory Management In uniprogramming system, memory is divided into two parts: for the.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Memory Management Chapter 5 Advanced Operating System.
1 Memory Management n In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes.
2010INT Operating Systems, School of Information Technology, Griffith University – Gold Coast Copyright © William Stallings /2 Memory Management.
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.
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.
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 Chapter 7.
ITEC 202 Operating Systems
Main Memory Management
Chapter 8: Main Memory.
Main Memory Background Swapping Contiguous Allocation Paging
Memory Management Chapter 7.
Lecture 3: Main Memory.
Operating System Chapter 7. Memory Management
Presentation transcript:

Memory Management Five Requirements for Memory Management to satisfy: –Relocation Users generally don’t know where they will be placed in main memory May want to swap in at a different place –Must deal with user pointers Generally handled by hardware –Protection Prevent processes from interfering with the O.S. or other processes Often integrated with relocation –Sharing Allow processes to share data/programs –Logical Organization Support modules, shared subroutines –Physical Organization Manage mem  disk transfers

Techniques Table 7.1, page 306 Fixed Partitioning –Divide memory into partitions at boot time, partition sizes don’t change –Simple but has internal fragmentation Dynamic Partitioning –Create partitions as programs loaded –Avoids internal fragmentation, but must deal with external fragmentation Simple Paging –Divide memory into equal-size pages, load program into available pages Pages do not need to be consecutive –No external fragmentation, small amount of internal fragmentation

Techniques Simple Segmentation –Divide program into segments Each segment is contiguous, but different segments need not be –No internal fragmentation, some external fragmentation Virtual-Memory Paging –Like simple paging, but not all pages need to be in memory at one time –Allows large virtual memory space –More multiprogramming, overhead Virtual Memory Segmentation –Like simple segmentation, but not all segments need to be in memory at one time –Easy to share modules –More multiprogramming, overhead

Fixed Partitioning Memory is divided into a set of partitions, each holds one program May have same or different sizes –(Figure 7.2, page 307) Equal-sized partitions –Program may be too large for one partition Programmer must handle overlays –Program may not be big enough to need a full partition Results in internal fragmentation

Fixed Partitioning Variable-sized partitions –Can fit partition size to program size –Placement Which partition do we use? –Want to use smallest possible partition –What if there are no large jobs waiting? Can have a queue for each partition size, or one queue for all partitions Easy to implement Limits degree of multiprocessing –Fixed at start time by # of partitions Tends to use memory poorly, especially for small programs (internal fragmentation) –Will work if the job sizes can be predicted in advance Used by IBM OS/MFT, obsolete

Dynamic Partitioning Create a new partition for each program Only allocate space required Tends to create “holes” as processes are swapped in and out (external fragmentation) Fig 7.4: pg. 310

Dynamic Partitioning Tends to generate small holes in memory (external fragmentation) Compaction –Shifting processes so all of the available memory is in one block –Requires processor time to move items around in memory –Requires relocation hardware that can handle the change in addresses Cannot easily find all possible addresses in the program Need to move program without changing user addresses

Dynamic Partitioning Placement –Best-Fit: Find the smallest available block that will hold the program Tends to produce a lot of small blocks –Use 30K block for 28K program, leaves 2K –First-Fit: Find the first block that is large enough (regardless of size) May leave small blocks at the beginning, larger blocks at the end of memory –Next-Fit: Like First-Fit, but start from the last allocation instead of the start Tends to break up large blocks at the end of memory that First-Fit leaves alone –Comparison: Figure 7.5, page 312 –First-Fit generally best, fastest Replacement Algorithm –Who gets swapped out? (Chapter 8)

Buddy System Tries to allow a variety of block sizes while avoiding excess fragmentation Blocks generally are of size 2 k, for a suitable range of k Initially, all memory is one block All sizes are rounded up to 2 s If a block of size 2 s is available, allocate it Else find a block of size 2 s+1 and split it in half to create two buddies If two buddies are both free, combine them into a larger block Largely Replaced by paging –Seen in parallel systems and Unix kernel memory allocation

Buddy System Example Figure 7.6, page 314 Representation of used and free nodes as a tree: Figure 7.7, page 315

Relocation Not a major problem with fixed- sized partitions –Easy to load process back into the same partition Otherwise need to deal with a process loaded into a new location Memory addresses may change –When loaded into a new partition –If compaction is used Addresses –Logical Addresses As seen by the program Often set as relative to the program start –Physical Addresses As seen by memory Hardware does address conversion

Base/Bounds Relocation Figure 7.8, page 317 Base Register –Holds beginning physical address –Add to all program addresses Bounds Register –Used to detect accesses beyond the end of the allocated memory –May have length instead of end address –Provides protection to system Easy to move programs in memory –Change base/bounds registers Largely replaced by paging

Paging Divides memory into small (4K or less) pieces of memory (frames) Logically divide program into same-size pieces (pages) Use a page table to map the pages of the current process to the corresponding frames in memory Example (Figure 7.9, page 318):

Paging Continued Page Tables for previous example (Figure 7.10, page 319) Page size typically a power of 2 to simplify the paging hardware –Example (16-bit address, 1K pages) Top 6 bits (010101)= page # Bottom 10 bits ( ) = offset within page –Common sizes: 512 bytes, 1K, 4K

Segmentation Program views memory as a set of segments of varying sizes –Easy to handle growing data structures –Easy to share libraries, memory –Privileges can be applied to a segment –Programs may use multiple segments Have a segment table –Beginning address –Size –Present, Modified, Accessed bits –Permission/Protection bits