FOR FREE CONTENT

Dining Philosopher Question-NET and GATE

 

Question GATE-2000

 

Let m[0] .........m[4] be mutexes (binary semaphore) and P0 ..... P4 be processes. Suppose each process P[i] executes the following:

 

            wait (m[i]) ;    wait (m[i+1] mod 4)

            CS

            release (m[i]);    release (m[i+1] mod 4)

 

Which situation could be came 

 

a) Thrashing 

b) Deadlock    

c) Starvation but no deadlock 

d) None

 

Answer:

 

This is question is related to the dining philosopher problem. (See Dining Philosopher problem

 

P means Down or Wait operation of binary semaphore.

 

P or Down operation cannot execute by two processes together for a single semaphore variable. If one process already runs a P or Down operation, then for the next process P or Down operation will be blocked for the same semaphore variable.

 

How it executes as per the above code P0, P1, P2, P3, P4

 

       

As if we know very well that this situation can be deadlock because this is exactly a dining philosopher problem.

 

Let take an example where deadlock will occur. 

 

 

                                                                       

So, it is a deadlock. Option b is correct.

 

UGC NET Paper –III 52

 

Dining philosopher’s problem is a 

a) Producer-Consumer problem 

b) Classical IPC problem 

c) Starvation problem

d) Synchronization problem.

 

Answer: 

 

a) It is not a producer-consumer problem because the producer-consumer problem is a different classical problem. 

 

Option a wrong.

 

b)  We discuss all classical problems above and the Dining philosopher problem is one of the classical problems. (See Dining philosopher problem).

 

So, Option b is correct.

 

c) No obviously dining philosopher is not a starvation problem because it removes deadlock. For more details (See Dining philosopher problem). 

 

Option c is wrong.

 

d) Dining philosopher problem is doing synchronization because it removes deadlock but it is a category of the classical problem.

 

So, Option b is a more correct answer than d.