Skip to main content

Compaction vs coalescing; paging mapping

Short answer

Compaction moves processes together to combine all free space into one; coalescing merges adjacent free blocks without relocating processes. Paging maps logical address by splitting into page number and offset; page table translates page to frame, and physical address = frame×size + offset. Example: with 4KB pages, address 9000 (page 2, offset 808) maps to frame 1 giving physical 4904.

Differentiate compaction and Coalescing technique. How is logical address mapped to physical address by Paging Technique? Explain with suitable example.

Compaction vs coalescing

PointCoalescingCompaction
MeaningJoins adjacent free blocks into one larger blockShifts all used blocks to one end so free space becomes one block
TriggerWhen a block is released next to a free blockWhen free memory exists but is split into small holes
Process movementNoneProcesses are relocated
OverheadVery lowHigh (copying, changing base addresses)
RequirementNoneDynamic (run-time) relocation
Removes external fragmentationOnly partlyCompletely

Example: free blocks 100 K and 50 K next to each other form a 150 K block after coalescing. Memory with P1 (40 K), hole 20 K, P2 (30 K), hole 25 K: compaction moves P2 down next to P1, giving one 45 K hole.

Mapping logical to physical address in paging

Logical memory is split into pages and physical memory into frames of equal size (power of 2). The CPU generates a logical address = (page number p, offset d). The page table (one per process) gives the frame number f for page p. Physical address = (f × page size) + d. The offset is unchanged.

 logical addr           page table           physical memory
 +----+----+          +---+-----+            frame f
 | p  | d  |-- p --> | p |  f  |-- f -->  +---------+
 +----+----+          +---+-----+          |  ...d.. |

Example: page size = 4 KB (4096), logical address = 9000. Page table: page 0 → frame 3, page 1 → frame 6, page 2 → frame 1.

  • p = 9000 div 4096 = 2; d = 9000 mod 4096 = 808.
  • Page 2 is in frame 1.
  • Physical address = 1 × 4096 + 808 = 4904.

Paging avoids external fragmentation but may have internal fragmentation in the last page of a process.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Operating System chapter 4 questions →