CS FundamentalsHardGATE CS
In the dining philosophers problem with 5 philosophers, each picks up the LEFT fork and then the RIGHT fork. Which change by itself guarantees freedom from deadlock?
- A. Each philosopher waits a fixed 1 ms between picking up the two forks
- B. Use a counting semaphore initialised to 5 to limit philosophers at the table
- C. Philosopher 4 picks up the right fork first; all others pick left first
- D. Make every philosopher put down both forks after eating
Correct answer: C. Philosopher 4 picks up the right fork first; all others pick left first
One asymmetric philosopher breaks the circular wait. A table limit works only with at most 4 (not 5) seated philosophers; fixed delays do not prevent all grabbing their left fork together.
More Operating Systems questions
- Readers–writers with readers' preference: semaphores mutex = 1 (protects readcount), wrt = 1. Reader: wait(mutex); readcount++; if…
- A bounded buffer of size N uses semaphores empty = N, full = 0, mutex = 1. Producer: wait(empty); wait(mutex); add; signal(mutex)…
- Monitors versus semaphores: in a Hoare-style monitor, when a process executes x.signal() and some process is waiting on condition x, which…
- Why must a Mesa-style condition wait be written as while (!cond) wait(c); rather than if (!cond) wait(c);?
- How many times is "x" printed? (Every fork() succeeds.) c int main() { if (fork() == 0) { fork(); fork(); } else { fork(); } printf("xn")…
- How many processes print "x" (including the original)? (Every fork() succeeds.) c int main() { for (int i = 0; i < 4; i++) if (fork() !=…