Question: We modify the code for Philosopher i in the following way: do { wait(X); wait(chopstick[i]); wait(chopstick[(i+1) % 5]); eat signal(chopstick[i]); signal(chopstick[(i+1) % 5]); think signal(X);
We modify the code for Philosopher i in the following way:
do {
wait(X);
wait(chopstick[i]);
wait(chopstick[(i+1) % 5]);
eat
signal(chopstick[i]);
signal(chopstick[(i+1) % 5]);
think
signal(X);
} while (1);
Above X is a shared semaphore variable initialized to 1.
| a. | The modified code prevents race conditions; but it doesn't solve the deadlock problem. | |
| b. | The modified code solves the deadlock problem; but it doesn't prevent race conditions. | |
| c. | The modified code prevents deadlock and race conditions; at the same time it provides maximum concurrency. | |
| d. | The modified code prevents deadlock and race conditions; but it doesn't provide maximum concurrency. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
