Systems CourseC/C++ · Linux · Memory
OS Memory & SystemsLesson 26 of 441 min read7 questions

Allocation Methods & Fragmentation

Contiguous vs paging vs segmentation; internal vs external waste.

Test yourself ↓

Concept core idea Watch out easy to get wrong

Concept

Key concepts

  1. Allocation schemes: contiguous (one block per process), and non-contiguous — paging (fixed pages) and segmentation (variable logical segments).
  2. External fragmentation = wasted gaps BETWEEN allocations (contiguous & segmentation suffer it). Paging cures it.
  3. Internal fragmentation = wasted space INSIDE the last page of a region (paging causes a little; ≤ page size − 1).
  4. Internal frag hits only the last page because every earlier page is completely full.
  5. External fragmentation is a problem, not a method — you don't choose it; contiguous allocation suffers it, paging avoids it.

Segmentation in one line

Divide by MEANING (code/data/stack) into variable-size segments; address = (segment number, offset); segment table holds base+limit (limit = protection). Great for per-segment permissions/sharing, but variable size + contiguous placement brings external fragmentation back. Modern OSes use paging (often under a thin segmentation layer).

Watch out

Easily confused

internal vs external fragmentation
Internal = waste INSIDE an allocated block (last page). External = waste in gaps BETWEEN blocks.
paging vs segmentation
Paging = fixed-size pages, avoids external frag, small internal frag. Segmentation = variable logical segments, great for protection/sharing, but external frag returns.
problem vs method
External fragmentation is a side effect (problem). Paging/segmentation/contiguous are methods. You don't 'do external fragmentation'.

Test yourself

7 questions on this lesson. Write your answers from memory, then compare them with the model answers side by side.