This page is a drill. We take the two formulas from the parent topic and beat them against every kind of input they can face — clean numbers, exact fits, tiny processes, huge processes, the degenerate "one hole" case, a word problem, and an exam trap.
Before we start, three symbols carry the whole page. We define them from zero:
The ⌈⌉ marks are the ceiling — "round up to the next whole number". We read ⌈2.44⌉=3 as: "2.44 blocks doesn't exist, so you need 3 whole blocks." Why up and never down? Because rounding down would leave some of the process's bytes with no home — illegal. Every leftover byte forces a fresh block.
Total free:40+30+50=120 K.
Why this step? The ratio compares the biggest usable piece against all the free memory.
Largest block:max(40,30,50)=50 K (the amber bar in the figure).
Ratio:1−50/120=1−0.4167=0.5833.
Why this step? A ratio near 1 means the free memory is badly shattered; here over half is unusable for any request above 50 K.
The 100 K request: must land in one contiguous hole. Largest is 50 K <100 K → fails, even though 120>100.
Why this step? Memory handed to a process must be contiguous; you cannot stitch three separate holes together for one request.
Verify:0.5833≈7/12; and indeed 1−50/120=(120−50)/120=70/120=7/12. ✓ Request fails because no single hole ≥100 K.
Slide A, B, C to the front: all used blocks pack against one end (top of figure → bottom).
Why this step? Compaction physically copies allocated blocks together; this requires run-time relocatable addresses (a base/relocation register), else the copied code would point at the wrong places.
Holes merge: the freed space becomes one block of 40+30+50=120 K.
Why this step? Nothing was freed or created — the same 120 K is now contiguous instead of scattered.
New ratio:1−120/120=0.
100 K request:120≥100 in one block → succeeds.
Why this step? Now a single hole is large enough, which is exactly what the request needs.
Verify: total free unchanged (120 K before and after — compaction moves, never deletes); ratio dropped 0.5833→0. ✓ And 120≥100, so success. Note internal waste inside A, B, C is untouched — compaction cures external only.
Internal formula ::: ⌈S/B⌉B−S; zero only when S is a multiple of B; worst case B−1; system total = sum of tails (≈B/2 each on average).
External ratio ::: 1−total freelargest free block; equals 0 for one hole, rises toward 1 as memory shatters; compaction drives it to 0 without changing total free.