1 / 15

Lecture 14 Memory Management III

Lecture 14 Memory Management III. Variable Partition Allocation. Variable Partitions. The number, location, and size of the partitions vary dynamically as processes come and go Improves memory utilization. Process is allocated exactly as much memory as required

clio-moreno
Download Presentation

Lecture 14 Memory Management III

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 14 Memory Management III Variable Partition Allocation M.B. Ibáñez

  2. Variable Partitions • The number, location, and size of the partitions vary dynamically as processes come and go • Improves memory utilization. Process is allocated exactly as much memory as required • The number and size of the processes in memory vary dynamically throughout the day • Complicates allocating and deallocating memory M.B. Ibáñez

  3. OS OS OS OS process 5 process 5 process 5 process 5 process 9 process 9 process 8 process 10 process 2 process 2 process 2 process 2 Example M.B. Ibáñez

  4. OS OS OS OS OS OS OS 128 K 320 K 320 K 320 K 320 K 320 K 320 K Process 1 Process 1 Process 1 Process 1 Process 1 Process 1 128 K 128 K 224 K 224 K Process 4 Process 4 Process 2 Process 2 96 K 96 K 896 K 576 K Process 3 288 K Process 3 288 K Process 3 Process 3 288 K 288 K 64 K 64 K 64 K 64 K External fragmentation problem OS 320 K Process 1 224 K Process 3 288 K 64 K M.B. Ibáñez

  5. OS 320 K Process 1 128 K Process 4 96 K Process 3 288 K 64 K Solution: Compaction OS 320 K Process 1 128 K Process 4 288 K Process 3 Process 5 100K 60K M.B. Ibáñez

  6. Placement algorithms revisited • Best-fit • Chooses the block that is closest in size to the request • worst performer overall • since smallest block is found for process, the smallest amount of fragmentation is left memory compaction must be done more often M.B. Ibáñez

  7. Placement algorithms revisited • First-fit • Begins to scan memory from the beginning and chooses the first available block that is large enough • fastest • may have many process loaded in the front end of memory that must be searched over when trying to find a free block M.B. Ibáñez

  8. Placement algorithms revisited • Next-fit • Begins to scan memory from the location of the last placement and chooses the next available block that is large enough. • more often allocate a block of memory at the end of memory where the largest block is found • the largest block of memory is broken up into smaller blocks • compaction is required to obtain a large block at the end of memory M.B. Ibáñez

  9. 8K 8K 12K 12K First Fit 22K 6K Best Fit Last allocated block (14K) 18K 2K 8K 8K 6K 6K Allocated block Free block 14K 14K Next Fit 36K 20K Before After Placement algorithmsExample M.B. Ibáñez

  10. Memory Managementwith Bit Maps • Memory is divided up into allocation units, perhaps as small as few words and perhaps as large as several kilobytes • Corresponding to each allocation unit is a bit in the bit map, which is 0 if the unit is free and 1 if it is occupied • A bit map provides a simple way to keep track of memory words in a fixed amount of memory because the size of the bit map depends only on the size of memory and the size of the allocation unit M.B. Ibáñez

  11. Memory Managementwith Bit Maps M.B. Ibáñez

  12. Memory Managementwith Linked Lists • Another way of keeping track of memory is maintaining a linked list of allocated and free memory segments. • A segment is either a process or a hole between two processes M.B. Ibáñez

  13. Memory Managementwith Linked Lists M.B. Ibáñez

  14. Memory Managementwith the Buddy System • Available blocks of size 2k, L≤ k ≤U • 2L is the smallest block that is allocated • 2U is the largest size block that is allocated • To begin, the entire space available for allocation is treated as a single block of size 2U • if a request of size s such as 2U-1 < s ≤ 2U is made, then the entire block is allocated • Otherwise, the block is split into two equal buddies of size 2U-1. (The process is repeated) M.B. Ibáñez

  15. Memory Managementwith the Buddy System M.B. Ibáñez

More Related