In a system with highly variable memory request sizes, which scenario best illustrates when the buddy system might perform worse than a slab allocator in terms of fragmentation?
hard⚖️ Approach Comparison Q8 of Q15
Operating Systems - Internal vs External Fragmentation - Compaction & Buddy System
In a system with highly variable memory request sizes, which scenario best illustrates when the buddy system might perform worse than a slab allocator in terms of fragmentation?
AWhen requests are mostly for small, fixed-size objects leading to high internal fragmentation in buddy system
BWhen requests are large and vary widely, causing external fragmentation in slab allocator
CWhen memory is heavily fragmented externally, buddy system compaction is more efficient
DWhen requests are random sizes but slab allocator cannot merge free slabs
Step-by-Step Solution
Solution:
Step 1: Understand buddy system internal fragmentation
Buddy system allocates blocks in powers of two, causing waste for small fixed-size requests.
When requests are mostly for small, fixed-size objects leading to high internal fragmentation in buddy system correctly identifies when buddy system suffers more internal fragmentation; When requests are random sizes but slab allocator cannot merge free slabs incorrectly states slab allocator cannot merge free slabs; When requests are large and vary widely, causing external fragmentation in slab allocator incorrectly states slab allocator causes external fragmentation; When memory is heavily fragmented externally, buddy system compaction is more efficient misattributes compaction efficiency.
Final Answer:
Option A -> Option A
Quick Check:
Buddy system wastes space on small fixed-size allocations [OK]
Quick Trick:Buddy system wastes space on small fixed-size allocations [OK]
Common Mistakes:
MISTAKES
Assuming buddy system always outperforms slab allocator
Confusing external fragmentation with internal
Trap Explanation:
PITFALL
Candidates overlook slab allocator's efficiency for small fixed-size objects compared to buddy system.
Interviewer Note:
CONTEXT
Assesses ability to compare allocation strategies under edge cases.
Master "Internal vs External Fragmentation - Compaction & Buddy System" in Operating Systems
2 interactive learning modes - each teaches the same concept differently