Practice
Solution
Step 1: Understand SSTF's goal
SSTF selects the closest request to the current head position to minimize seek time.Step 2: Consider starvation risk
SSTF can cause starvation for requests far from the current head position because it always picks the nearest request.Step 3: Compare with SCAN and C-SCAN
SCAN and C-SCAN move the head in a fixed direction to provide fairness and avoid starvation, sacrificing some seek time efficiency.Final Answer:
Option A -> Option AQuick Check:
When minimizing average seek time is the highest priority and starvation is acceptable correctly identifies SSTF's strength and its tradeoff with starvation risk.
- Assuming SSTF always avoids starvation
- Believing SCAN/C-SCAN minimize seek time better than SSTF
- Confusing uniform distribution with SSTF suitability
Solution
Step 1: Understand resource sharing in threads
Threads within the same process share memory and resources, allowing efficient communication and lower overhead compared to processes.Step 2: Compare overhead of context switching
Thread context switching is lighter than process context switching, making threads better for high concurrency.Step 3: Evaluate options
Use multiple processes, each handling a single client request independently uses processes, which have higher overhead and less efficient resource sharing. Use a single-threaded process with blocking I/O for all requests is single-threaded and blocks, limiting concurrency. Use multiple processes with shared memory segments for communication adds complexity with shared memory and still has process overhead.Final Answer:
Option A -> Option AQuick Check:
Threads maximize resource sharing and minimize overhead for concurrent tasks [OK]
- Assuming processes are always better for concurrency
- Ignoring context switching overhead differences
- Believing shared memory between processes is as simple as threads
Solution
Step 1: Understand deadlock conditions
Deadlock occurs when each process holds a resource and waits for the other, causing indefinite blocking.Step 2: Analyze the immediate aftermath
Neither process releases resources voluntarily, so both remain blocked indefinitely (both processes remain blocked indefinitely, waiting for the other to release the resource). Both processes releasing their held resources and retrying immediately is incorrect because processes do not release resources spontaneously. The operating system preempting one process to break the deadlock automatically is incorrect as OS preemption is not automatic in typical deadlock. Both processes entering a livelock, continuously retrying without progress describes livelock, which involves active state changes, not blocking.Final Answer:
Option A -> Option AQuick Check:
Deadlock means indefinite waiting without resource release, matching both processes remain blocked indefinitely, waiting for the other to release the resource.
- Assuming OS automatically resolves deadlock
- Confusing deadlock with livelock
Solution
Step 1: Analyze Paging eliminates external fragmentation but can cause internal fragmentation
Paging does eliminate external fragmentation but may cause internal fragmentation; this is true.Step 2: Analyze Segmentation always provides better memory protection than paging
Segmentation provides logical division but does not inherently guarantee better protection than paging; protection depends on implementation.Step 3: Analyze Paging requires fixed-size blocks, which simplifies memory allocation
Paging uses fixed-size pages, simplifying allocation; this is true.Step 4: Analyze Segmentation can lead to external fragmentation due to variable segment sizes
Segmentation can cause external fragmentation due to variable segment sizes; this is true.Final Answer:
Option C -> Option CQuick Check:
Protection depends on hardware and OS, not solely on segmentation.
- Assuming segmentation always improves protection
- Ignoring internal fragmentation in paging
- Overlooking external fragmentation in segmentation
Solution
Step 1: Understand weak memory ordering impact
Modern processors may reorder instructions, causing visibility issues for shared variables.Step 2: Effect on Peterson's algorithm
Without memory barriers, the flags and turn variables may be seen out of order, breaking mutual exclusion.Step 3: Solution
Inserting memory fences/barriers enforces ordering and visibility, preserving correctness.Final Answer:
Option D -> Option DQuick Check:
Memory barriers are essential on weakly ordered architectures for software synchronization.
- Assuming Peterson's works without modification on all hardware
- Confusing deadlock with visibility delays
- Believing atomic variables alone guarantee correctness
