Main Memory Management
❑ Introduction to Memory Management
❑ Basic Main Memory Allocation Strategies
Memory Manager
• It must ensure that the memory spaces of processes are protected
so that unauthorized access is prevented.
• It must ensure that each process has enough memory space to be
able to execute.
• It must keep track of the memory locations used by each process.
It should also know which part of the memory is free to use.
Memory Management Unit (MMU)
• special hardware device used for mapping logical address to its
corresponding physical address.
1. Fixed-partition memory allocation strategies
In fixed partitioning, the main memory is divided into a fixed number
of regions or partitions.
Internal Fragmentation
If the size of the partition is larger than the size of the process, this
leads to wastage of memory.
External Fragmentation
wastage of memory which occurs when there are partitions available
but none are big enough for any waiting process.
2. Variable-partition memory allocation strategies
Variable partitioning simply allocates the exact memory space
needed by each process.
Example:
A computer system has a 32-MB main memory with the operating
system occupying the first 4 MB. The following processes are inside
the job queue:
OS 4MB OS 4MB OS 4MB
P1 12MB P1 12MB
P2 7MB
28MB 16MB
9MB
OS 4MB OS 4MB OS 4MB
P1 12MB P1 12MB P1 12MB
P2 7MB P4 5MB
7MB
2MB
P3 8MB
P3 8MB P3 8MB
1MB 1MB
1MB
Three (3) Placement strategies in variable partitioning
• First-fit strategy
• Best-fit strategy
OPERATING
• Worst-fit strategy SYSTEM
4 MB
P1 4 MB
4 MB
2 MB P2 3 MB
P4
3 MB
Incoming
Process
P3 8 MB
6 MB
32 MB Main Memory
Compaction
moving the processes upwards in main memory so that the free
memory locations may be grouped together in one large block.
OPERATING OPERATING
4 MB 4 MB
SYSTEM SYSTEM
P1 4 MB P1 4 MB
4 MB P2 3 MB
P2 3 MB
P3 8 MB
3 MB
P3 8 MB
13 MB
6 MB
Before Compaction After Compaction