The buddy memory allocation algorithm Παρουσίαση 11.02.2009: Δρ. Αναγνωστό π ουλος Χρήστος.

Slides:



Advertisements
Similar presentations
Chapter 6: Memory Management
Advertisements

1 Optimizing Malloc and Free Professor Jennifer Rexford COS 217 Reading: Section 8.7 in K&R book
Fixed/Variable Partitioning
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
7. Physical Memory 7.1 Preparing a Program for Execution
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.
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.
Dynamic memory allocation and fragmentation Seminar on Network and Operating Systems Group II.
Memory Management Memory Areas and their use Memory Manager Tasks:
Multiprocessing Memory Management
Memory Management Chapter 7 B.Ramamurthy. Memory Management Subdividing memory to accommodate multiple processes Memory needs to allocated efficiently.
1 Optimizing Malloc and Free Professor Jennifer Rexford
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 Chapter 5.
Computer Organization and Architecture
Memory Management Five Requirements for Memory Management to satisfy: –Relocation Users generally don’t know where they will be placed in main memory May.
Chapter 7 Memory Management
Memory Allocation CS Introduction to Operating Systems.
The memory allocation problem Define the memory allocation problem Memory organization and memory allocation schemes.
Real-Time Concepts for Embedded Systems Author: Qing Li with Caroline Yao ISBN: CMPBooks.
Review of Memory Management, Virtual Memory CS448.
Memory Management Chapter 7.
Dynamic Partition Allocation Allocate memory depending on requirements Partitions adjust depending on memory size Requires relocatable code –Works best.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Dynamic Storage Allocation Algorithms for Allocation  First-Fit  Best-Fit  Worst-Fit.
Memory Management COSC 513 Presentation Jun Tian 08/17/2000.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 9.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Operating System Concepts and Techniques Lecture 8
Memory Management Problem: Records (of various lengths) need to be stored. Model: A big array of space to store them, managed by a memory manager. Like.
Chapter 17 Free-Space Management Chien-Chung Shen CIS, UD
CS 241 Discussion Section (11/17/2011). Outline Review of MP7 MP8 Overview Simple Code Examples (Bad before the Good) Theory behind MP8.
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 -Memory allocation -Garbage collection.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Memory Management Overview.
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
CS 241 Discussion Section (2/9/2012). MP2 continued Implement malloc, free, calloc and realloc Reuse free memory – Sequential fit – Segregated fit.
CS 241 Discussion Section (12/1/2011). Tradeoffs When do you: – Expand Increase total memory usage – Split Make smaller chunks (avoid internal fragmentation)
External fragmentation in a paging system Use paging circuitry to map groups of noncontiguous free pages into logically contiguous addresses (remap your.
Fall 2000M.B. Ibáñez Lecture 14 Memory Management II Contiguous Allocation.
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 Damian Gordon.
Memory Management One of the most important OS jobs.
Memory Management Chapter 7.
Chapter 7 Memory Management
Chapter 17 Free-Space Management
Memory Management Chapter 7.
Memory Management Memory Areas and their use Memory Manager Tasks:
Day 19 Memory Management.
Day 19 Memory Management.
Partitioned Memory Allocation
Upper Bound for Defragmenting Buddy Heaps
Day 18 Memory Management.
Memory Management Memory Areas and their use Memory Manager Tasks:
PURE Mid-Progress Report
Optimizing Malloc and Free
CS Introduction to Operating Systems
Memory Management Overview
Memory Management (1).
Presentation made by Steponas Šipaila
Dynamic Memory Allocation
Memory Management Memory Areas and their use Memory Manager Tasks:
Presentation transcript:

The buddy memory allocation algorithm Παρουσίαση : Δρ. Αναγνωστό π ουλος Χρήστος

1963, H. Markowitz Easy implementation (80286, …) Little external fragmentation (enough memory is free to satisfy a request, but it is split into chunks none of which is big enough to satisfy the request) Moderate internal fragmentation (the requested memory is a little larger than a small block, but a lot smaller than a large block) Example: Request of 66K of memory would be allocated 128K (waste: 62K memory) Memory allocation in powers of 2, i.e., 2 k, k > 0. The programmer decides on: The upper limit ( u ) of k The lower limit ( l ) of k Example: Memory of 2000K. The u is k = 10, i.e., 2 10 = 1024K –the biggest “allocatable” block. The l is k = 2, i.e., 2 2 = 4K –the smallest “allocatable” block minimizing internal fragmentation and large enough to avoid overhead.

Algorithm buddy ( l, u, request) Begin If (memory.request == allocation) Then Lock memory m of size as the minimal 2 k block that is larger than request. size If m is available Then allocate() Else Split free memory m larger than the request. size into half If m.size is the minimal 2 k block and not lower than l Then allocate() Goto::Lock Repeat until m is found Else If (memory.request == free) Then Free memory m While neighbor( m ) == free or m < u Do m = merge( m, neighbor( m )) /* #compaction = log 2 ( u / l )*/ End While End If End.

Running Example I: l = 6 that is 2 6 = 64K u = 10 that is 2 10 = 1024K Requests: 0. Program A: 64K 1. Program B: 128K 2. Program C: 64K 3. Program D: 128K 4. Program C: ends 5. Program A: ends 6. Program B: ends 7. Program D: ends ΑΑΒΑ C Β ABDBDD ACBD split freeallocated 1024K ?. Program D: 130K ?. Program C: 503K ?. Program C: 260K

Running Example II: l = 6 that is 2 6 = 64K u = 10 that is 2 10 = 1024K Requests: 0. Program A: 100K 1. Program B: 240K 2. Program C: 64K 3. Program D: 256K 4. Program B: ends 5. Program A: ends 6. Request E: 75K 7. Program C: ends 8. Program E: ends 8. Program D: ends Α Α B Α C A AC D freeallocated 1024K B B C C D D C ED ED D

The buddy memory allocation algorithm Bib: D. Knuth, “The Art of Computer Programming”, vol. 1, Fundamental Algorithms, 2 nd Ed., 1997, pp