A system has resources , and processes . The implementation of the resource request logic of each process is as follows:
In which of the following situations is a deadlock possible?
View worked solution
Answer: B
To determine if a deadlock is possible, let us analyze the resource request patterns of the processes:
1. Even-indexed processes ( where is even):
- Request first, then .
- They only request even-indexed resources in a strictly increasing order of indices ().
2. Odd-indexed processes ( where is odd):
- Request first, then .
- They request resources in a strictly decreasing order of indices.
- If is even, and are odd. Thus, odd processes only request odd-indexed resources. Since even and odd processes access completely disjoint sets of resources, no interaction occurs, making deadlock impossible. This rules out options A and C.
- If is odd, and are even. Thus, both even and odd processes compete for even-indexed resources. Since one group requests them in increasing order and the other in decreasing order, a deadlock cycle can form.
Let us test the remaining options with odd :
- Option B ():
Consider process (even) and (odd):- requests then .
- requests then .
- Option D ():
The maximum index requested by any even process is (requested by ). The minimum index requested by any odd process is (requested by ). Since the resource sets and are disjoint, no deadlock can occur.
Free practice · Your answers on this page are not saved.
