External fragmentation in a paging system Use paging circuitry to map groups of noncontiguous free pages into logically contiguous addresses (remap your.

Slides:



Advertisements
Similar presentations
Chapter 6: Memory Management
Advertisements

Chapter 2: Memory Management, Early Systems
Chapter 2: Memory Management, Early Systems
Note on malloc() and slab allocation CS-502 (EMC) Fall A Note on malloc() and Slab Allocation CS-502, Operating Systems Fall 2009 (EMC) (Slides include.
The Linux Kernel: Memory Management
Memory Management in Linux (Chap. 8 in Understanding the Linux Kernel)
Kernel memory allocation
Kernel Memory Allocator
Chapter 12. Kernel Memory Allocation
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.
CS 311 – Lecture 21 Outline Memory management in UNIX
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
Memory Management Memory Areas and their use Memory Manager Tasks:
Chapter 3.1 : Memory Management
Memory Management A memory manager should take care of allocating memory when needed by programs release memory that is no longer used to the heap. Memory.
Chapter 5: Memory Management Dhamdhere: Operating Systems— A Concept-Based Approach Slide No: 1 Copyright ©2005 Memory Management Chapter 5.
Memory Management Five Requirements for Memory Management to satisfy: –Relocation Users generally don’t know where they will be placed in main memory May.
1 Chapter 3.1 : Memory Management Storage hierarchy Storage hierarchy Important memory terms Important memory terms Earlier memory allocation schemes Earlier.
Memory Management Joe O’Pecko CS-520-A. What is Memory Management? The art and the process of coordinating and controlling the use of memory in a computer.
Memory Allocation CS Introduction to Operating Systems.
The memory allocation problem Define the memory allocation problem Memory organization and memory allocation schemes.
CS 346 – Chapter 8 Main memory –Addressing –Swapping –Allocation and fragmentation –Paging –Segmentation Commitment –Please finish chapter 8.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 32 Paging Read Ch. 9.4.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Dynamic Partition Allocation Allocate memory depending on requirements Partitions adjust depending on memory size Requires relocatable code –Works best.
1. Memory Manager 2 Memory Management In an environment that supports dynamic memory allocation, the memory manager must keep a record of the usage of.
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
1 Advanced Memory Management Techniques  static vs. dynamic kernel memory allocation  resource map allocation  power-of-two free list allocation  buddy.
Chapter 17 Free-Space Management Chien-Chung Shen CIS, UD
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.
Memory Management -Memory allocation -Garbage collection.
Virtual Memory – Managing Physical 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)
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 4.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Memory Management One of the most important OS jobs.
Memory Management Chapter 7.
Memory Management Chapter 7.
Memory Management Memory Areas and their use Memory Manager Tasks:
Chapter 2: The Linux System Part 4
Chapter 2 Memory and process management
Day 19 Memory Management.
Day 19 Memory Management.
Memory Allocation The main memory must accommodate both:
Partitioned Memory Allocation
Day 18 Memory Management.
Memory Management Memory Areas and their use Memory Manager Tasks:
Main Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
CS Introduction to Operating Systems
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
Chapter3 Memory Management Techniques
Main Memory Background Swapping Contiguous Allocation Paging
Chapter 8: Memory management
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.
Presentation made by Steponas Šipaila
Dynamic Memory Allocation
Memory Management Memory Areas and their use Memory Manager Tasks:
Page Main Memory.
Presentation transcript:

External fragmentation in a paging system Use paging circuitry to map groups of noncontiguous free pages into logically contiguous addresses (remap your addresses to make them contiguous) use a “best fit” algorithm when allocating contiguous frames of memory (Linux uses this approach)

The Buddy System Algorithm Lists of free Frames All free page frames are grouped into one of 10 lists of blocks. The physical address of the first frame of a given block (of frames) is a multiple of the size of that block. (For example, the initial address of a 16-page frame block is a multiple of 16 x 2 12 )

The Buddy System Algorithm When a request for a contiguous block comes in, the OS searches the list for the smallest block bigger than the request. If nothing is available, it searches the next larger block list and continues this process iteratively until it either finds a block to allocate or discovers that the request cannot be granted. If a block is bigger than the request, it is split into pieces which are put into their appropriate lists.

The Buddy System Algorithm (Deallocation) The algorithm gets it name from its reclaiming technique: Because of the addressing scheme (The physical address of the first frame of a given block is a multiple of the size of that block) each block is associated with an adjacent block of the same size. Upon deallocation, if the “buddy” block is free, we can collapse the two blocks into one of twice the size. We then repeat this process iteratively until a “buddy” block is not free:

The Buddy System Algorithm (Deallocation) ffffufufufuuuuu u f = used = free u We’re going to deallocate this one

The Buddy System Algorithm (Deallocation) ffffufffufuuuuu u f = used = free u New contiguous block Next, deallocate this block

The Buddy System Algorithm (Deallocation) ffffffffufuuuuu u f = used = free f New contiguous block

The Buddy System Algorithm (Deallocation) ffffffffufuuuuu u f = used = free f New contiguous block

Handling Internal Fragmentation The original solution: allocate memory size by powers of 2, instead of by the size of the data to be stored. Why? How does this work?

Internal Fragmentation: slab allocation Often, memory allocation requests are for the same type of objects such as process control blocks, file descriptors, etc. The kernel can use this fact by storing memory that has been used and released (called a slab) in a cache where, when a similar request comes in for the same type of object, the kernel does not have to reallocate that memory, it just returns a previously-used slab. The slab allocater does not handle deallocation on its own.