Practice
Solution
Step 1: Understand the initial action
Each philosopher picks up their left fork simultaneously, so all forks on the left side are held.Step 2: Analyze waiting condition
Each philosopher now waits for the right fork, which is held by their neighbor, creating a circular wait.Step 3: Identify the system state
This circular wait with no forks released leads to deadlock.Final Answer:
Option C -> Option CQuick Check:
Deadlock arises immediately due to circular wait and mutual exclusion.
- Assuming philosophers can eat simultaneously
- Confusing deadlock with starvation
- Believing system recovers automatically without intervention
Solution
Step 1: Analyze memory overhead
Threads share memory, so they have lower memory overhead than processes, making Because threads have higher memory overhead than processes incorrect.Step 2: Consider synchronization issues
Shared memory requires synchronization mechanisms (locks, mutexes), which can cause contention and reduce performance.Step 3: Evaluate context switching speed
Thread context switching is generally faster than process switching, so Because thread context switching is slower than process context switching is false.Step 4: Understand CPU core utilization
Threads can run on multiple cores simultaneously, so Because threads cannot run on multiple CPU cores simultaneously is false.Final Answer:
Option C -> Option CQuick Check:
Synchronization overhead can limit thread performance gains [OK]
- Assuming threads always outperform processes
- Confusing context switch overhead between threads and processes
- Believing threads cannot utilize multiple cores
Solution
Step 1: Understand starvation in preemptive SJF
Shorter jobs can continuously preempt longer ones, causing longer processes to wait indefinitely.Step 2: Analyze other options
A: While context switches increase, CPU utilization remains high; overhead is a concern but not utilization.
B: Preemptive SJF generally reduces average turnaround time, not increases it.
D: Preemptive SJF is designed to handle processes arriving at different times.Final Answer:
Option B -> Option BQuick Check:
Starvation is a classic drawback of preemptive SJF.
- Confusing turnaround time impact
- Assuming preemptive SJF cannot handle dynamic arrivals
Solution
Step 1: Understand resource ordering
Ordering resources prevents circular wait by forcing processes to request resources in a global order.Step 2: Identify drawbacks
Strict ordering can cause processes to wait longer than necessary, reducing concurrency and system throughput.Step 3: Analyze other options
The system can still deadlock due to hold and wait despite ordering is incorrect because ordering eliminates circular wait, thus preventing deadlock from that condition. No preemption condition is violated by enforcing ordering is false; ordering does not violate no preemption. Mutual exclusion is no longer required when ordering is enforced is false; mutual exclusion is still required for non-shareable resources.Final Answer:
Option A -> Option AQuick Check:
Ordering trades off concurrency for deadlock prevention.
- Believing ordering removes all deadlock conditions
- Confusing ordering with preemption
- Assuming mutual exclusion is eliminated by ordering
Solution
Step 1: Classic solution assumes fixed buffer size
Semaphore 'empty' initialized once to buffer size; dynamic resizing breaks this assumption.Step 2: Adjusting semaphore counts
When buffer grows, 'empty' semaphore must be incremented atomically to reflect new slots; otherwise, producers may block unnecessarily.Step 3: Why other options are incorrect
Consumers must signal the 'empty' semaphore twice per consumed item is false; consumers do not signal 'empty' twice. Mutex locks become ineffective with dynamic buffer sizes is false; mutex still protects critical section regardless of size. Producers will never block because buffer is always large enough is false; producers can still block if buffer is full.Final Answer:
Option B -> Option BQuick Check:
Dynamic buffer size requires careful semaphore count updates [OK]
- Assuming fixed semaphore counts suffice for dynamic buffers
- Thinking mutex depends on buffer size
- Misunderstanding producer blocking conditions
