I am not sure how to properly detect deadlocks. My book provides this table for five processes P0 to P4 and three resource types A, B, and C. Resource A has seven instances, resource type B has two instances, and resource type C has six instances. This is the resource-allocation state at time T0:
Allocation Request Available
A B C A B C A B C
P0 0 1 0 0 0 0 0 0 0
P1 2 0 0 2 0 2
P2 3 0 3 0 0 0
P3 2 1 1 1 0 0
P4 0 0 2 0 0 2
It goes on to state that the system is not in a deadlocked state, but does not provide much detail for the problem solving technique. Can anyone break it down for me so that I may follow along with the steps easily and attempt a similar problem?
Here is my attempt at understanding the problem:
P0 has 1 of resource B and requires no resources. P0 relinquishes its resources
A B C A B C A B C
P0 0 0 0 0 0 0 0 1 0
P1 2 0 0 2 0 2
P2 3 0 3 0 0 0
P3 2 1 1 1 0 0
P4 0 0 2 0 0 2
P1 has 2 of resource A and requires 2 of resource A and C. There are not enough resources available. P2 has 3 of resource A and C and requires no resources. P2 relinquishes its resources.
A B C A B C A B C
P0 0 0 0 0 0 0 3 1 3
P1 2 0 0 2 0 2
P2 0 0 0 0 0 0
P3 2 1 1 1 0 0
P4 0 0 2 0 0 2
Hope I’m on the right track thus far.
Deadlocks occur when you once process is in the state “have A, need B” and some other process is in “have B, need A”.
if I’m reading your tables right, then this would indicate a deadlock:
P0 has resource B, and requires resource A, with no more resource A’s available
P1 has 2 of resource A, and requires source B, with no more B’s available.
The deadlock cannot be resolved until more of resources A or B become available. That’d mean P0 or P1 have to relinquish some of their allocations (or P2+ doing the same).