Practice
Solution
Step 1: Identify Peterson's solution scope
Peterson's algorithm is designed specifically for two processes to achieve mutual exclusion without hardware support.Step 2: Analyze other options
When multiple processes (more than two) need to synchronize access to a shared resource is incorrect because Peterson's solution does not scale beyond two processes. When processes require synchronization but can tolerate starvation is wrong because Peterson's solution guarantees bounded waiting, preventing starvation. When the system supports preemptive multitasking with priority-based scheduling is irrelevant since Peterson's algorithm is independent of scheduling policies.Final Answer:
Option A -> Option AQuick Check:
Peterson's solution is a classic two-process synchronization algorithm without hardware atomic instructions.
- Assuming Peterson's works for more than two processes
- Confusing bounded waiting with starvation allowance
- Believing hardware support is required
Solution
Step 1: Understand Optimal Algorithm's Principle
The Optimal algorithm evicts the page that will not be used for the longest time in the future, which requires knowledge of future requests.Step 2: Analyze Each Option
When the system can predict future page requests accurately is correct because Optimal needs future knowledge to be effective.
When the system has very limited memory and needs a simple algorithm is incorrect because Optimal is complex and not simple.
When the workload is highly random and unpredictable is incorrect because unpredictability makes future knowledge impossible.
When the system wants to minimize implementation complexity is incorrect because Optimal is the most complex to implement.Final Answer:
Option C -> Option CQuick Check:
Optimal is theoretical and best when future requests are known.
- Assuming Optimal is practical without future knowledge
- Confusing simplicity with effectiveness
- Believing Optimal works well with random workloads
Solution
Step 1: Initialize FIFO with empty frames
Frames: []Step 2: Process each page in order
1 -> fault, frames: [1]
2 -> fault, frames: [1,2]
3 -> fault, frames: [1,2,3]
4 -> fault, evict 1, frames: [4,2,3]
1 -> fault, evict 2, frames: [4,1,3]
2 -> fault, evict 3, frames: [4,1,2]
5 -> fault, evict 4, frames: [5,1,2]
1 -> hit
2 -> hit
3 -> fault, evict 1, frames: [5,3,2]
4 -> fault, evict 2, frames: [5,3,4]
5 -> hitStep 3: Count faults
Total faults = 9Final Answer:
Option B -> Option BQuick Check:
FIFO evicts oldest page regardless of future use, causing 9 faults here.
- Counting hits as faults
- Misordering evictions in FIFO
- Forgetting to update frames after eviction
Solution
Step 1: Identify the event
The process requests I/O while Running, so it must wait for I/O completion.Step 2: State transition on I/O request
Process moves from Running to Waiting state to wait for I/O.Step 3: After I/O completes
Process moves from Waiting to Ready state, waiting for CPU scheduling.Step 4: CPU scheduling
Process moves from Ready to Running when CPU is allocated.Final Answer:
Option A -> Option AQuick Check:
Running -> Waiting (I/O request), Waiting -> Ready (I/O done), Ready -> Running (CPU assigned) [OK]
- Confusing Ready and Waiting states order
- Assuming process goes directly from Waiting to Running
- Skipping the Ready state after I/O completion
Solution
Step 1: Understand timeout-based fork release
Philosophers release forks if waiting too long, preventing indefinite blocking.Step 2: Analyze consequences
This can cause livelock, where philosophers continuously pick up and release forks without making progress.Step 3: Evaluate other options
It completely eliminates deadlock and starvation without any performance penalty is false because performance penalties and livelock can occur; It simplifies synchronization by removing the need for semaphores or locks is false as synchronization primitives are still needed; It guarantees fairness by enforcing strict turn-taking among philosophers is false as fairness is not guaranteed.Final Answer:
Option B -> Option BQuick Check:
Timeouts prevent deadlock but risk livelock due to repeated retries.
- Assuming timeouts solve all synchronization issues
- Confusing livelock with deadlock
- Believing fairness is guaranteed by timeouts
