Deadlock Detection Algorithm
available[1..m] ; # of available resources
allocation[1..n,1..m] ;# of resource of each Ri allocated to Pj
request[1..n,1..m] ; # of resources of each Ri requested by Pj
for all i < n, if allocation [i] not 0
then finish[i]=false else finish[i]=true
2. find an index i such that:
if no such i exists, go to 4.
3. work=work+allocation[i]
finish[i] = true, go to 2
4. if finish[i] = false for some i, then system is deadlocked with Pi in deadlock