in Unknown Category edited by
519 views
1 vote
1 vote

Consider a system with five processes $P_0$ through $P_4$ and three resource types $A, B$ and $C$. Resource type $A$ has seven instances, resource type $B$ has two instances and resource type $C$ has six instances suppose at time $T_0$ we have the following allocation.

If we implement Deadlock detection algorithm we claim that system is ________

  1. Semaphore
  2. Deadlock state
  3. Circular wait
  4. Not in deadlock state
in Unknown Category edited by
by
519 views

2 Answers

1 vote
1 vote

The deadlock detection algo investigates every possible allocation sequences for the processes that remain to be completed.

The total allocated resources to all processes of resource type B doesn't match with that mentioned in the question. If we ignore the statement and take the tables as the right one then the solution is as follows:

Process P0 and P2 have been allocated all its resources and hence will run till completion. They will give up the resources they were allocated. This is the state:

Available:  A = 3    B = 1    C = 3

Processes left: P1   P3   P4

Process P1 requires: A = 2   B = 0   C = 2

We can fulfill its request. It will be allocated all the resources and will run till completion. Then it will give up all the resources. Now this will be the state:

Available: A = 5    B = 1    C = 3

Processes left: P3   P4

Similarly, next process P3 will be executed first and then P4.

Ans: option 4.

3 Comments

In the last state of processes:

How C=3 it should be 5, like A=5 (3+2) B=1(1+0)  then C=5 (3+2).
0
0
Before executing process P1 available resources:

A = 3    B = 1     C = 3

For process P1, we allocate the resources it requires which is:

A = 2   B = 0    C=2

After P1 completes execution we get back the resources it was allocated recently + the resources it was already holding. Resources P1 was already holding:

A = 2    B = 0     C = 0

Thus total available resources after P1

A = (3 - 2 + 2 + 2)

B = (1 + 0)

C = (3 - 2 + 2 + 0)

This is a very common mistake people make solving these type of questions. Try solving the question on your own, you'll find out the mistake you made. I allocated the resources it required by the process, ran it till execution, got back the recently allocated resources + the already allocated resources it had got earlier.
1
1
Now I got it right. I usually did this miscalculation in other questions too. Its all sorted. Thanks a lot.
0
0
0 votes
0 votes
D. Not in deadlock..
Answer:

Related questions