Q6: Is the system deadlocked?

Question #6: Consider the following situation with processes named A to G and resources named R to W:

1. Process A holds R and wants S.

2. Process B holds nothing but wants T.

3. Process C holds nothing but wants S.

4. Process D holds U and wants S and T.

5. Process E holds T and wants V.

6. Process F holds W and wants S.

7. Process G holds V and wants U.

Is this system deadlocked?

Options:

A)   No, all processes can go ahead and finish the job eventually.

B)   Yes, since there is a cycle in resource allocation graph.

C)   There may be a deadlock, can’t say deterministically.

D)   There is a race condition but deadlock may or may not be there.

Solution: Let’s model the above scenario in the form of resource allocation graph. Let square blocks represent resources and circled blocks represent processes.

resource allocation

For example, A holds R is represented by an arrow from R to A. A wants S is represented by an arrow from A to S. Since there is a cycle of resource hold and want, there is a deadlock in the system. Hence, the correct answer is B.