Paging vs Segmentation - Address Translation - Watch the Algorithm Execute, Step by Step
Watching each step of address translation helps you understand how virtual memory maps to physical memory, clarifying the roles of segments and pages without needing to read dense code.
✓ Address translation combines segmentation and paging by first validating the segment and then mapping pages within it.
This layered approach is hard to grasp from code alone but becomes clear when you see each lookup and calculation step.
✓ Offset validation against segment limit prevents illegal memory access, a critical safety check.
Visualizing this check shows why segmentation protects memory boundaries.
✓ Page faults are detected during page table lookup, showing when the system must load pages from disk.
Seeing the decision point for page faults clarifies how virtual memory handles missing pages.
Practice
(1/5)
1. Which component is primarily responsible for saving and restoring CPU registers during a context switch?
easy
A. The Interrupt Handler
B. The CPU scheduler
C. The Memory Management Unit (MMU)
D. The Process Control Block (PCB)
Solution
Step 1: Understand the role of PCB
The PCB stores the CPU register states and other process information needed to resume execution later.
Step 2: Differentiate from scheduler and interrupt handler
The scheduler decides which process runs next but does not save registers; the interrupt handler triggers context switches but does not save registers itself.
Step 3: MMU role
The MMU handles memory address translation, unrelated to register saving.
Final Answer:
Option D -> Option D
Quick Check:
PCB contains saved CPU state -> correct component for saving/restoring registers.
Hint: PCB = process snapshot including CPU registers [OK]
Common Mistakes:
Confusing scheduler with register saving
Assuming interrupt handler saves registers
Thinking MMU handles CPU state
2. Which of the following statements best explains why eliminating the 'No Preemption' condition is often impractical in operating systems?
medium
A. Preemption increases the chance of circular wait conditions.
B. Preemption always leads to starvation of some processes.
C. Preempting resources can cause inconsistent states and data corruption if not handled carefully.
D. Preemption is unnecessary because hold and wait can be eliminated instead.
Solution
Step 1: Understand 'No Preemption'
This condition means resources cannot be forcibly taken from a process.
Step 2: Analyze why preemption is hard
Preempting resources like CPU or I/O devices can cause inconsistent states or data corruption if the process is interrupted mid-operation.
Step 3: Evaluate other options
Preemption always leads to starvation of some processes is incorrect because preemption does not always cause starvation; proper scheduling can prevent it. Preemption increases the chance of circular wait conditions is false; preemption reduces circular wait. Preemption is unnecessary because hold and wait can be eliminated instead is misleading; eliminating hold and wait is difficult and does not negate the challenges of preemption.
Final Answer:
Option C -> Option C
Quick Check:
Preemption risks inconsistent states, making it impractical in many cases.
Hint: No preemption exists because forcibly taking resources risks corruption [OK]
Common Mistakes:
Believing preemption always causes starvation
Confusing preemption effects with circular wait
Assuming eliminating hold and wait removes need for preemption
3. Which of the following statements best describes a limitation of the buddy system in managing memory fragmentation?
medium
A. It can cause significant internal fragmentation due to rounding up allocation sizes to powers of two
B. It completely eliminates external fragmentation by merging all free blocks
C. It requires compaction to handle fragmentation effectively
D. It is inefficient for fixed-size memory allocation requests
Solution
Step 1: Analyze buddy system behavior
Buddy system allocates blocks in powers of two, causing internal fragmentation when requested size is not a power of two.
Step 2: Evaluate other options
It does not eliminate external fragmentation completely (B); compaction is a separate technique (C); it is efficient for fixed-size allocations (D is incorrect).
Final Answer:
Option A -> Option A
Quick Check:
Internal fragmentation is a known trade-off in buddy system [OK]
Hint: Buddy system = power-of-two blocks -> internal fragmentation [OK]
Common Mistakes:
Believing buddy system removes all external fragmentation
Confusing compaction as part of buddy system
Assuming buddy system is inefficient for variable sizes
4. In a system with multiple CPUs (multi-core), how does context switching overhead differ compared to a single-core system, and what additional factors must be considered?
hard
A. Context switching overhead per CPU remains the same, but inter-CPU cache coherence and synchronization add extra overhead
B. Context switching overhead is eliminated because each CPU runs its own process independently
C. Context switching overhead doubles because each CPU must save and restore registers twice
D. Context switching overhead is reduced because the scheduler can switch processes faster across CPUs
Solution
Step 1: Per-CPU context switch cost
Each CPU still saves/restores registers during context switches, so overhead per CPU is similar to single-core.
Step 2: Additional multi-core factors
Multi-core systems require cache coherence protocols and synchronization mechanisms, adding overhead beyond single-core context switching.
Step 3: Misconceptions
Context switching is not eliminated; CPUs do not save/restore registers twice per switch; scheduler speedup is not guaranteed.
Believing scheduler is always faster on multi-core
5. If a process in the Waiting state is waiting for multiple I/O events simultaneously, how does the five-state model handle this scenario, and what is a key limitation of the model in this context?
hard
A. The process moves to Ready state after the first I/O event completes, ignoring others, which can cause errors
B. The process remains in Waiting until all I/O events complete; the model does not distinguish multiple waits, limiting concurrency handling
C. The process splits into multiple processes for each I/O event, which the model explicitly supports
D. The process moves to Running state and polls each I/O event, which the model assumes
Solution
Step 1: Understand Waiting state semantics
Waiting means blocked until the awaited event(s) complete.
Step 2: Multiple I/O waits in five-state model
The model treats Waiting as a single state without differentiating multiple simultaneous waits.
Step 3: Limitation
This means the process stays in Waiting until all I/O events complete, limiting fine-grained concurrency.
Final Answer:
Option B -> Option B
Quick Check:
Five-state model does not handle multiple simultaneous waits distinctly [OK]
Hint: Waiting state is a single block; multiple waits are not distinguished [OK]
Common Mistakes:
Assuming process moves to Ready after any I/O completes
Believing process can split into multiple processes automatically
Thinking process polls I/O events while Running
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.