Dynamic Partition Allocation Allocate memory depending on requirements Partitions adjust depending on memory size Requires relocatable code –Works best.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Chapter 6: Memory Management
Memory Management Chapter 7.
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
Chapter 7 Memory Management
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.
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.
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.
Computer Organization and Architecture
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
1 Chapter 3.1 : Memory Management Storage hierarchy Storage hierarchy Important memory terms Important memory terms Earlier memory allocation schemes Earlier.
1 Lecture 8: Memory Mangement Operating System I Spring 2008.
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.
Paging. Memory Partitioning Troubles Fragmentation Need for compaction/swapping A process size is limited by the available physical memory Dynamic growth.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally MEMORYMANAGEMNT.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
Memory Management. Process must be loaded into memory before being executed. Memory needs to be allocated to ensure a reasonable supply of ready processes.
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Dr.
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.
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. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
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 Basics. 2 Program P Basic Memory Management Concepts Address spaces Physical address space — The address space supported by the hardware.
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.
Basic Memory Management 1. Readings r Silbershatz et al: chapters
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.
Deadlock Avoidance Determine whether, by allowing allocation, we could get a deadlock, i.e. check if by allowing allocation the system could enter a state.
Memory Management Chapter 7.
Chapter 7 Memory Management
Memory Management Chapter 7.
Paging.
Memory Management.
Chapter 2 Memory and process management
Chapter 8: Main Memory.
Memory Allocation The main memory must accommodate both:
Partitioned Memory Allocation
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.
Multistep Processing of a User Program
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
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.
Lecture 3: Main Memory.
Memory Management (1).
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Page Main Memory.
Presentation transcript:

Dynamic Partition Allocation Allocate memory depending on requirements Partitions adjust depending on memory size Requires relocatable code –Works best with relocation registers

Dynamic Partition Allocation Program 1 Program 2 Program 3

External Fragmentation Program 1 Program 2 Program 3 These fragments are not allocated to any program, and they are wasted.

Allocation Policies Best Fit First Fit Worst Fit Rotating First Fit

First Fit Allocation To allocate n bytes, use the first available free block such that the block size is larger than n. 500 bytes 1K bytes 2K bytes To allocate 400 bytes, we use the 1st free block available 2K bytes 500 bytes

Rationale & Implementation Simplicity of implementation Requires: Free block list sorted by address Allocation requires a search for a suitable partition Deallocation requires a check to see if the freed partition could be merged with adjacent free partitions (if any)

First Fit Allocation Advantages Simple Tends to produce larger free blocks toward the end of the address space Disadvantages External fragmentation

Best Fit Allocation To allocate n bytes, use the smallest available free block such that the block size is larger than n. 500 bytes 1K bytes 2K bytes To allocate 400 bytes, we use the 3rd free block available (smallest) 1K bytes 2K bytes

Rationale & Implementation To avoid fragmenting big free blocks To minimize the size of external fragments produced Requires: Free block list sorted by size Allocation requires search for a suitable partition Deallocation requires search + merge with adjacent free partitions, if any

Best Fit Allocation Advantages Works well when most allocations are of small size Relatively simple Disadvantages External fragmentation Slow allocation Slow deallocation Tends to produce many useless tiny fragments (not really great)

Worst Fit Allocation To allocate n bytes, use the largest available free block such that the block size is larger than n. 500 bytes 1K bytes 2K bytes To allocate 400 bytes, we use the 2nd free block available (largest) 1K bytes

Rationale & Implementation To avoid having too many tiny fragments Requires: Free block list sorted by size Allocation is fast (get the largest partition) Deallocation requires merge with adjacent free partitions, if any, and then adjusting the free block list

Worst Fit Allocation Advantages Works best if allocations are of medium sizes Disadvantages External fragmentation Tends to break large free blocks such that large partitions cannot be allocated

How bad is external fragmentation? (Knuth) H: # of holesS: # of used segments blue: when released, H is decreased by 1 green: when released, H is unchanged red: when released, H is increased S = b+g+r H = (2b+g+  )/2 At equilibrium, b = r S = b+g+r = 2b+g = 2H or H = S/2 number of holes is half of number of segments!

Compaction (Burping) Program 1 Program 2 Program 3 Program 1 Program 2 Program 3

Multiprogramming Multiprogramming: Ability to run more than one program simultaneously Early systems: degree of multiprogramming had to be large to maximize the return on hardware investment Multiprogramming requires all programs to be resident in memory simultaneously –Can be done by partitioned memory allocation, but –Size of memory limits the number of programs that can run simultaneously

Swapping Allows to schedule more programs simultaneously than the memory can accommodate –Use a partition on disk to “extend” the main memory –Processes are added until memory is full –If more programs need to be loaded, pick one program and save its partition on disk (the process is swapped out, cannot run) –Later, bring the process back from disk (process is swapped in) and swap out another process Done on an all-or-nothing basis –The entire process is either in memory or on swap space (cannot be between both),

Memory & Scheduling StartReadyRunning I/O Wait Done Process creation, resources allocated Process loaded in main memory Process waiting for I/O Done Resources deallocated I/O requested I/O done Zombie Swapped out Process on disk

Memory & Scheduling (cont’d) Need two levels of scheduling: –Upper level decides on swapping: When Who For how long –Lower level decides on who actually runs on the CPU (what we have covered so far) Upper level is invoked if there are processes swapped out, and whenever we need to load more programs than can fit in main memory

Paging

Memory Partitioning Troubles Fragmentation Need for compaction/swapping A process size is limited by the available physical memory Dynamic growth of partition is troublesome No winning policy on allocation/deallocation P2 P3

The Basic Problem A process needs a contiguous partition(s) But Contiguity is difficult to manage Contiguity mandates the use of physical memory addressing (so far)

The Basic Solution Give illusion of a contiguous address space The actual allocation need not be contiguous Use a Memory Management Unit (MMU) to translate from the illusion to reality

A solution: Virtual Addresses Use n-bit to represent virtual or logical addresses A process perceives an address space extending from address 0 to 2 n -1 MMU translates from virtual addresses to real ones Processes no longer see real or physical addresses

Paged Memory Subdivide the address space (both virtual and physical) to “pages” of equal size Use MMU to map from virtual pages to physical ones Physical pages are called frames

Paging: Example 00 Virtual Physical Process 0 Process 1