Contiguous Allocation in OS: Fixed and Dynamic Partitions, Algorithms and Exam Traps
Learn why free memory can still reject a process. Trace fixed partitions, dynamic holes, and first fit, best fit, and worst fit with checked calculations.
KnowledgeGate Team
Exam prep & CS education

A process can fail despite enough total free memory when the bytes are not one uninterrupted block. Base and limit registers, partition waste, and three placement algorithms explain how contiguous allocation works. The one-process fit comparison in Memory Management in Operating Systems: Paging, Virtual Memory and Worked Examples uses the same five-hole map; extending the arrival sequence to four processes exposes order effects and rejection after successive placements.
Contiguous allocation in OS from zero
Contiguous allocation gives each process one unbroken physical-memory interval beside protected OS space and free holes. Non-contiguous schemes relax this rule.
Base and limit registers provide relocation and protection. With base 12,000 and limit 3,500 bytes, the processor verifies 0 <= offset < 3,500, then adds the base.
Offset
0maps to physical address12,000.Offset
3,499maps to12,000 + 3,499 = 15,499.Offset
3,500is invalid because it equals the limit.
Checking first protects the next block. Within CS Fundamentals, fixed partitioning divides memory in advance; dynamic partitioning creates each process's block.
Fixed partitioning and internal fragmentation
Split 1,000 KB into partitions of 100, 200, 300, and 400 KB. Assign P1=90 KB, P2=180 KB, P3=260 KB, and P4=350 KB respectively.
Process | Partition | Process size | Unused inside partition |
|---|---|---|---|
P1 | 100 KB | 90 KB |
|
P2 | 200 KB | 180 KB |
|
P3 | 300 KB | 260 KB |
|
P4 | 400 KB | 350 KB |
|
Process memory is 90 + 180 + 260 + 350 = 880 KB. Internal fragmentation is 10 + 20 + 40 + 50 = 120 KB; 880 + 120 = 1,000 KB checks the total. Each wasted piece lies inside an allocated partition, so it is internal waste, not an external hole.

Dynamic partitioning and external fragmentation
Dynamic partitioning carves one block to the requested size. Terminated processes leave holes that later activity can scatter between live processes.
In address order, use H1=100 KB, H2=500 KB, H3=200 KB, H4=300 KB, and H5=600 KB. Total free memory is 100 + 500 + 200 + 300 + 600 = 1,700 KB.
External fragmentation occurs when separate holes cannot meet a one-block request. Holes are outside processes; internal waste is inside a partition.
First fit, best fit and worst fit rules
Algorithm | Selection rule |
|---|---|
First fit | Scan from the low-address end and choose the first adequate hole. |
Best fit | Choose the smallest adequate hole. |
Worst fit | Choose the largest adequate hole. |
For ties, choose the lower address. Keep the remainder in the same position. First fit restarts at H1 for every process, unlike next fit.
No rule always wins. Results depend on holes and arrival order.
Worked example for all three algorithms
Start with holes [100, 500, 200, 300, 600] KB. Admit P1=212 KB, P2=417 KB, P3=112 KB, and P4=426 KB, in that order.
First fit
Process | Chosen hole | Subtraction | Remaining holes in address order |
|---|---|---|---|
P1 212 | H2 500 |
|
|
P2 417 | H5 600 |
|
|
P3 112 | H2 remainder 288 |
|
|
P4 426 | None | No hole |
|
P4 fails: 100 + 176 + 200 + 300 + 183 = 959 KB is free, but the largest hole is 300 KB.
Best fit
Process | Chosen hole | Subtraction | Remaining holes in address order |
|---|---|---|---|
P1 212 | H4 300 |
|
|
P2 417 | H2 500 |
|
|
P3 112 | H3 200 |
|
|
P4 426 | H5 600 |
|
|
All four fit. Holes total 100 + 83 + 88 + 88 + 174 = 533 KB. Demand is 212 + 417 + 112 + 426 = 1,167 KB; 1,700 - 1,167 = 533 KB.
Worst fit
Process | Chosen hole | Subtraction | Remaining holes in address order |
|---|---|---|---|
P1 212 | H5 600 |
|
|
P2 417 | H2 500 |
|
|
P3 112 | H5 remainder 388 |
|
|
P4 426 | None | No hole |
|
Free memory again totals 959 KB, but the largest hole is 300 KB. Best fit wins only for this data and order.

Coalescing, compaction and paging
Coalescing merges adjacent free blocks. Compaction relocates live processes to combine scattered holes, requiring relocation support and data movement.
After first fit, compaction could turn five holes totalling 959 KB into one. P4=426 KB would fit and leave 959 - 426 = 533 KB. This fixes external fragmentation, not fixed-partition waste.
Memory Management in OS: Paging and Segmentation covers the boundary. Paging removes the single contiguous-block rule; paging and segmentation bring different translation questions.
Contiguous allocation question patterns and traps
Questions often trace allocations, calculate fragmentation, test an address, assess compaction, or identify a false statement.
Tempting answer | Correction |
|---|---|
P4 fits because 959 KB is free. | P4 needs one 426 KB hole; the largest is 300 KB. |
The fixed example has 120 KB external fragmentation. | The 120 KB is inside partitions, so it is internal. |
Offset 3,500 is the final valid offset. | Valid offsets end at 3,499. |
Best fit always gives the best result. | It succeeds only for this hole list and arrival order. |
Self-test: Which algorithm allocates all four processes? How much internal fragmentation does the fixed-partition example create? Does logical offset 3,500 pass a limit of 3,500?
Answers: best fit, 120 KB, and invalid. Practise with Memory and Paging MCQs: 12 Solved (GATE).
The short version and next step
One process needs one physical interval, as the base
12,000example shows.Fixed partitions create internal waste,
120 KBin the four-partition example.Dynamic partitions can leave external holes, so P4 fails despite
959 KBfree.First, best, and worst fit choose different adequate holes. Here, only best fit admits all four.
Coalescing joins adjacent holes, while compaction relocates live processes and could turn
959 KBinto one hole.
Cover the tables, recompute all three allocations from [100, 500, 200, 300, 600] KB, and redraw both diagrams. For a complete GATE CS plan, use GATE Guidance by Sanchit Sir.
Keep learning
File Allocation Methods in Operating Systems: Contiguous, Linked and Indexed Worked Examples
Compare contiguous, linked and indexed allocation by tracing the same file across disk blocks. Then calculate growth costs and a two-level index lookup.
Contiguous Allocation MCQs: 12 Solved Questions with Explanations
Solve 12 published contiguous allocation MCQs, then use stepwise hole lists and fragmentation checks to understand why each option is right.
First Fit, Best Fit and Worst Fit for GATE: Contiguous Memory Allocation Numericals Solved
Run the same process stream through First Fit, Best Fit and Worst Fit. The full trace shows why every hole must be updated after every allocation.
C Dynamic Memory Allocation, Macros, Scope and File Handling: 10 Mistakes
Trace ten common C mistakes from incorrect allocation sizes to broken file-reading loops. Each diagnosis shows why it happens, the exact failure and the safer repair.





