##### Concurrent processes and shared variables

explain

Gopi Shankar
12 Nov 2014 05:54 am

Here in each of the option except option 2 we are able to see a cycle, for instance in option 1 we have X engaging resource a -> resource c & Z engaging resource c -> resource a. Similar thing happens in option 3 and 4 as well.

Gopi Shankar
12 Nov 2014 05:58 am

One can try enumerating each resource in some priority order as well, if sharing of resource involve more than two processes, to unfold the cycle.

Vivek Vikram Singh
12 Nov 2014 01:08 pm

In A, in 1st P() operation, X ,Y and Z all will be proceeding by decrementing a from 1 to 0, b from 1 to 0 and c from 1 to 0. Current values of a,b and c are 0  and d=1.

in 2nd P() operation in all processes, X and Y will be stuck as b and c are having 0. The only process ,which will be proceeding , is Z.values of a,b,c,d=0.

in 3rd and final operation for Z, Z is doing wait operation on a, which is having value 0. So Z will also be  waiting. So this case all processes are deadlocked. option A is eliminated. This way you can eliminate all other options C and D as well.

Lets look at the option B.

In 1st set of P() operations of all processes, X and Y doing signal operation on b.Lets assume each case separately.

1) Suppose X proceed first while Y get stuck in waiting. Z will be proceeding too as it can independently execute signal on a. So as of now we have 2 progressing process X and Z. values of a and b is 0 whereas c and d are having values 1.

in 2nd set of P() operation, X will be stuck as it is doing P() operation on a, which is having value 0,while Z can move further as c had value of 1 which will be decremented to 0. Current values of a,b,c is 0 and d=1.

in 3rd set of P() operations, Z will be decrement the value of d from 1 to 0 and goes to Critical Section. It is a deadlock free operation.

Got the Answer? Yes??? Nooooo. You are still missing one more case on the same option with Y proceeding instead of X.

2) in 1st set of operations , suppose this time Y gets proceed instead of X. X is stuck and Y and Z will move to next set of P() operations. values of a,b is 0 and c,d is 1.

in 2nd set of P(), either process can go ahead by decrementing value of c from 1 to 0 and in next set of P() operations, it can decrement value of d from 1 to 0 and enter critical section.

So in both the cases, this option B lead to Deadlock free operation.

Parimal Andhalkar
13 Nov 2014 09:09 am

got it thanks ...........