Warning: count(): Parameter must be an array or an object that implements Countable in /home/customer/www/thegatebook.in/public_html/qa/qa-include/qa-theme-base.php on line 177

# OS - Synchronization and Deadlock -Q8

Warning: count(): Parameter must be an array or an object that implements Countable in /home/customer/www/thegatebook.in/public_html/qa/qa-include/qa-theme-base.php on line 177

D number of friends go to a Chinese restaurant at a busy time of the day. The waiter apologetically explains that the restaurant can provide only a few chopsticks to be shared among the D people. Furthermore, each diner may require a different number of chopsticks to eat. For example, it is possible that one of the diners is an octopus, who for some reason refuses to begin eating before acquiring eight chopsticks. The second parameter of this scenario is C, the number of chopsticks that would simultaneously satisfy the needs of all diners at the table. For example, two octopus would result in C = 16.

$\dpi{100} A$ll the chopsticks provided by the waiter are placed in an empty glass at the center of the table and each diner obeys the following protocol:

$\dpi{100} A$cquire chopsticks one after one and start eating only after having the required number of chopsticks. If no more chopstick is available then Hold the current chopsticks and wait for more chopsticks. Once all chopsticks acquired, then eat and release all chopsticks.

$\dpi{100} A$lso while one person is using a chopstick then unless he releases it after completion of eating, it can not be shared with any other person(i.e. Chosticks are used in mutual exclusion manner).

$\dpi{100} W$hat is the smallest number of chopsticks (in terms of D and C) needed to ensure that deadlock cannot occur?

$\dpi{100} (A)$. C

$\dpi{100} (B)$. D

$\dpi{100} (C)$. C-D

$\dpi{100} (D)$. C-D+1