Bird
Raised Fist0

In the classic semaphore-based solution to Dining Philosophers, which of the following is a subtle bug that can cause starvation despite preventing deadlock?

medium🐞 Bug Identification Q7 of Q15
Operating Systems - Dining Philosophers - Problem, Deadlock & Solution
In the classic semaphore-based solution to Dining Philosophers, which of the following is a subtle bug that can cause starvation despite preventing deadlock?
AImplementing a global mutex to protect fork acquisition
BUsing a binary semaphore per fork without enforcing order
CAllowing philosophers to pick up forks only when both are available
DUsing a waiter to grant forks one at a time
Step-by-Step Solution
Solution:
  1. Step 1: Understand semaphore usage

    Binary semaphores per fork prevent simultaneous use but don't prevent starvation.
  2. Step 2: Analyze starvation cause

    Without enforced order or fairness, some philosophers may be perpetually blocked.
  3. Step 3: Evaluate other options

    Options A, B, and D implement ordering or centralized control reducing starvation risk.
  4. Final Answer:

    Option B -> Option B
  5. Quick Check:

    Binary semaphores alone don't guarantee starvation freedom [OK]
Quick Trick: No enforced order -> starvation possible despite no deadlock [OK]
Common Mistakes:
MISTAKES
  • Confusing deadlock prevention with starvation prevention
  • Assuming global mutex solves starvation
  • Believing waiter always prevents starvation
Trap Explanation:
PITFALL
  • Candidates often overlook starvation risk when only deadlock is addressed by semaphores.
Interviewer Note:
CONTEXT
  • Identifies candidate's grasp of starvation vs deadlock distinction.
Master "Dining Philosophers - Problem, Deadlock & Solution" in Operating Systems

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Operating Systems Quizzes