Computer Science · Operating Systems
Consider the proposed solution to the Dining Philosophers Problem using a binary semaphore 'lock' initialized to 1: Philosopher(int i) { while (1) { think(); wait(lock); // (i) wait(fork[i]); wait(fork[(i+1)%5]); signal(lock); // (ii) eat(); wait(lock); // (iii) signal(fork[i]); signal(fork[(i+1)%5]); signal(lock); // (iv) } } Which of the following statements is correct regarding statements (i), (ii), (iii), and (iv)?
- 1All statements (i), (ii), (iii), and (iv) are necessary; removing any pair could cause deadlock or mutual exclusion issues.✓
- 2Removing (i), (ii), (iii), and (iv) will keep the code deadlock-free.
- 3Removing (iii) and (iv) will not affect the code safety.
- 4Removing (i) and (ii) will not affect the code safety.
Correct answer
All statements (i), (ii), (iii), and (iv) are necessary; removing any pair could cause deadlock or mutual exclusion issues.
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on Operating Systems?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · Operating Systems