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

Updated 2 Dec 20265 min read
Contiguous Allocation in OS: Fixed and Dynamic Partitions, Algorithms and Exam Traps

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 0 maps to physical address 12,000.

  • Offset 3,499 maps to 12,000 + 3,499 = 15,499.

  • Offset 3,500 is 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

100 - 90 = 10 KB

P2

200 KB

180 KB

200 - 180 = 20 KB

P3

300 KB

260 KB

300 - 260 = 40 KB

P4

400 KB

350 KB

400 - 350 = 50 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.

Four fixed memory partitions hold P1 through P4, leaving 10, 20, 40, and 50 KB of internal waste, totalling 120 KB.

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

500 - 212 = 288

[100, 288, 200, 300, 600]

P2 417

H5 600

600 - 417 = 183

[100, 288, 200, 300, 183]

P3 112

H2 remainder 288

288 - 112 = 176

[100, 176, 200, 300, 183]

P4 426

None

No hole >= 426

[100, 176, 200, 300, 183]

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

300 - 212 = 88

[100, 500, 200, 88, 600]

P2 417

H2 500

500 - 417 = 83

[100, 83, 200, 88, 600]

P3 112

H3 200

200 - 112 = 88

[100, 83, 88, 88, 600]

P4 426

H5 600

600 - 426 = 174

[100, 83, 88, 88, 174]

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

600 - 212 = 388

[100, 500, 200, 300, 388]

P2 417

H2 500

500 - 417 = 83

[100, 83, 200, 300, 388]

P3 112

H5 remainder 388

388 - 112 = 276

[100, 83, 200, 300, 276]

P4 426

None

No hole >= 426

[100, 83, 200, 300, 276]

Free memory again totals 959 KB, but the largest hole is 300 KB. Best fit wins only for this data and order.

Memory holes and occupied blocks show first fit, best fit, and worst fit placement outcomes.

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,000 example shows.

  • Fixed partitions create internal waste, 120 KB in the four-partition example.

  • Dynamic partitions can leave external holes, so P4 fails despite 959 KB free.

  • 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 KB into 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.