Top Banner
Memory Management Chapter 7
14

Memory Management

Mar 21, 2016

Download

Documents

sagira

Memory Management. Chapter 7. Memory Management. Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as many processes into memory as possible should be able to run a program whose size is larger than the available real memory. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Memory Management

Memory ManagementChapter 7

Page 2: Memory Management

Memory Management

Subdividing memory to accommodate multiple processes

Memory needs to be allocated efficiently to pack as many processes into memory as possible

should be able to run a program whose size is larger than the available real memory

Page 3: Memory Management

Memory Management provides

Relocation Programmer (or the compiler) does not know where the

program will be placed in memory when it is executed

While the program is executing, it may be swapped to disk and returned to main memory at a different location (relocated)

Memory references in the code must be translated to actual physical memory addresses

Page 4: Memory Management

Protection

Processes should not be able to access memory locations that belong to another process without permission

Must be done at runtime OS cannot anticipate all of the memory references a program

will make

Sharing

Allow several processes to access the same portion of memory

Memory Management provides

Page 5: Memory Management

Fixed Partitioning

Memory is divided into equal-sized partitions which are assigned to processes on demand

or unequal-sized partitions

Memory use is inefficient. Any program, no matter how small, occupies an entire partition.

internal fragmentation

Page 6: Memory Management

Memory Assignment for Fixed Partitioning Equal-size partitions: no strategy is needed; it does not matter Unequal-size partitions

assign each process to the smallest partition within which it will fit. This way, we can minimize the wasted memory within a partition

Use one queue for each partition or a single queue for all

Page 7: Memory Management

Dynamic Partitioning

• Processes are allocated exactly as much memory as required

• Eventually holes will start appearing in the memory. This is called external fragmentation

• Must use compaction to shift processes so they are contiguous and all free memory is in one block

Page 8: Memory Management

Memory Allocation Strategies forDynamic Partitioning

Three popular strategies:

First-fit Fastest May have many processes loaded in the front end of memory that

must be searched over when trying to find a free block

Best-fit Chooses the block that is closest in size to the request Worst performer overall Since smallest block is found for a process external fragments

are smallest. Memory compaction must be done more often

Next-fit Similar to first fit but starts to search for free blocks beyond the

last allocated block Results in an even distribution of the free blocks throughout the

memory

Page 9: Memory Management

Memory Configuration Before and After Allocation of a 16 Mbyte Block

Page 10: Memory Management

Buddy System

Entire space available is treated as a single block of 2U

If a request of size s is such that 2U-1 < s ≤ 2U, entire block of 2U is allocated Otherwise block is split into two equal buddies Splitting continues until smallest block greater than or

equal to s is generated

Page 11: Memory Management
Page 12: Memory Management
Page 13: Memory Management

Paging

Partition memory into small equal-size chunks called frames

Divide each process into the same size chunks called pages

Operating system maintains a page table for each process

contains the frame location for each page in the process

Pages of process A

Page 14: Memory Management

Page Tables

456