
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes
When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state System is in safe state if there exists a safe sequence of all processes Sequence <P 1
2
n
is safe if for each P i , the resources that P i can still request can be satisfied by currently available resources + resources held by all the P j , with j<I If Pi resource needs are not immediately available, then Pi can wait until all Pj have finished When Pj is finished, P i can obtain needed resources, execute, return allocated resources, and terminate When Pi terminates, Pi +1 can obtain its needed resources, and so on
Claim edge P i
j indicated that process P j may request resource R j ; represented by a dashed line. Claim edge converts to request edge when a process requests a resource. When a resource is released by a process, assignment edge reconverts to a claim edge. Resources must be claimed a priori in the system.
Multiple instances. Each process must a priori claim maximum use. When a process requests a resource it may have to wait. When a process gets all its resources it must return them in a finite amount of time
Resource-Request Algorithm for Process P i Request = request vector for process P i
. If Request i [ j ] = k then process P i wants k instances of resource type R j.
The content of the matrix. Need is defined to be Max – Allocation. Need A B C P 0
1
2
3
4
The system is in a safe state since the sequence < P 1
3
4
2
0
satisfies safety criteria.
1
Check that Request ≤ Available (that is, (1,0,2) ≤ (3,3,2) ⇒ true_. Allocation Need Available A B C A B C A B C P_ 0
1
2
3
4
Executing safety algorithm shows that sequence <P1, P3, P4, P0, P2> satisfies safety requirement. Can request for (3,3,0) by P4 be granted? Can request for (0,2,0) by P0 be granted?
Maintain wait-for graph Nodes are processes. Pi → Pj if Pi is waiting for Pj. Periodically invoke an algorithm that searches for a cycle in the graph. An algorithm to detect a cycle in a graph requires an order of n 2 operations, where n is the number of vertices in the graph.
Resource-Allocation Graph Corresponding wait-for graph
Five processes P 0 through P 4 ; three resource types A (7 instances), B (2 instances), and C ( instances). Snapshot at time T 0
AllocationRequest Available A B C A B C A B C P 0
1
2
3
4
Sequence < P 0
2
3
1
4
will result in Finish [ i ] = true for all i