Consider the Dining-Philosophers problem (Chapter 5.7.3), in which a set of philosophers sit around a table…

Consider the Dining-Philosophers problem (Chapter 5.7.3), in
which a set of philosophers sit around a table with one chopstick
between each of them. Let the philosophers be numbered from 0 to
n_1 and be represented by separate threads. Each philosopher
executes Dine(i), where i is the philosophers number. Assume
that there is an array of semaphores, Chop[i] that represents the
chopstick to the left of philosopher i. These semaphores are
initialized to 1.
void Dine( int i )
{
Chop[ i ] .P(); /_ Grab left chopstick _/
Chop[( i+1)%n ] .P(); /_ Grab right chopstick _/
EatAsMuchAsYouCan ();
Chop[ i ] .V(); /_ Release left chopstick _/
Chop[( i+1)%n ] .V(); /_ Release right chopstick _/
}
This solution can deadlock. Assume that it does. List the four
conditions of deadlock and explain why each of them is satis_ed
during the deadlock.