1Definition
Contiguous Memory Allocation is a memory management scheme where each process is contained in a single continuous block of physical RAM addresses. It is classified into Fixed Partitioning (RAM divided into static fixed-size slots) and Dynamic Partitioning (RAM partitions created dynamically matching exact process size).
2Simple Explanation
- Fixed Partitioning: Imagine a parking lot with fixed concrete parking stalls, each 20 feet wide. If a small compact car (2MB process) parks in a 20-foot stall (4MB partition), 2MB of space inside the stall is wasted (Internal Fragmentation). If a massive semi-truck (6MB process) arrives, it cannot park anywhere because no single stall is big enough, even if the total empty space across stalls adds up to 10MB (External Fragmentation).
- Dynamic Partitioning: Instead of fixed concrete stalls, the parking lot has no lines. When a car arrives, the attendant draws lines matching the exact length of the car. This eliminates internal fragmentation! However, as cars enter and leave at different times, tiny unused gaps open up between parked cars. When a big truck arrives later, it cannot fit because the free space is split into non-contiguous gaps (External Fragmentation).
3Real-Life Example / Analogy
- Fixed Partitioning: Pill boxes with fixed plastic compartments. Putting a tiny pill in a large compartment leaves empty wasted volume inside the cell.
- Dynamic Partitioning: Cutting slices off a loaf of bread on demand. Each slice matches the exact size requested by a person.
4Diagram / Visual Representation
5Working / How It Works
- Fixed Partitioning: Main memory divided into static partitions at boot time -> Process arrives -> OS searches for free partition -> Process assigned to partition -> Unused space inside partition lost to Internal Fragmentation.
- Dynamic Partitioning: Main memory maintained as one large unpartitioned pool -> Process arrives -> OS carves out exact memory block matching process size -> Process executes -> Upon completion, partition freed back to pool -> Non-contiguous gaps lead to External Fragmentation.
6Types / Components / Characteristics
- Contiguous Allocation Comparison:
| Metric / Parameter | Fixed Partitioning | Dynamic Partitioning |
|---|---|---|
| Partition Size | Static (Declared at boot time) | Dynamic (Created on demand at process load) |
| Internal Fragmentation | Present (Process size < Partition size) | Zero (Partition size == Process size) |
| External Fragmentation | Present | Present (Unused non-contiguous holes) |
| Process Size Limit | Cannot exceed largest static partition | Limited only by total physical RAM |
| Degree of Multiprogramming | Fixed / Low | Dynamic / High |
7Solved Examples / Problems
Problem: Main memory has free non-contiguous holes of 3MB, 2MB, and 4MB (Total Free = 9MB). A new Process P5 requires 8MB. Can P5 be loaded under contiguous allocation? Solution: No. Under contiguous memory allocation, a process must be loaded into a single continuous memory block. Even though total free space (9MB) exceeds process size (8MB), the largest single contiguous hole is only 4MB. Thus, Process P5 fails to load due to External Fragmentation.
8Advantages, Disadvantages & Applications
- Fixed Partitioning Advantages: Simple algorithm, low OS management overhead.
- Disadvantages: Severe internal fragmentation, fixed degree of multiprogramming.
- Dynamic Partitioning Advantages: Zero internal fragmentation, high memory utilization.
- Disadvantages: External fragmentation requires costly memory compaction.
9Important Points to Remember
- Internal Fragmentation: Wasted space inside an allocated partition.
- External Fragmentation: Wasted space between partitions (total free space sufficient, but non-contiguous).
10Test Your Understanding
- MCQ: What type of memory fragmentation is completely eliminated by Dynamic Partitioning?
- A) External Fragmentation
- B) Internal Fragmentation
- C) Page Fault Fragmentation
- D) System Cache Fragmentation
Show answer
B. - Conceptual Question: Define Internal and External Fragmentation with clear diagrams.
- Application Question: Explain how fixed partition sizes constrain the Degree of Multiprogramming in an OS.
