Professional Documents
Culture Documents
13 Deadlock Intro Print PDF
13 Deadlock Intro Print PDF
CSCI 315 Operating Systems Design 5 CSCI 315 Operating Systems Design 6
1
Deadlock Characterization Resource Allocation Graph
Deadlock can arise if four conditions hold simultaneously:
Graph: G=(V,E)
• Mutual exclusion: only one process at a time can use a
resource.
• Hold and wait: a process holding at least one resource is • The nodes in V can be of two types (partitions):
waiting to acquire additional resources held by other
– P = {P1, P2, …, Pn}, the set consisting of all the
processes.
processes in the system.
p y
• No
N preemption:ti a resource can beb released
l d only
l voluntarily
l t il
by the process holding it, after that process has completed
its task. – R = {R1, R2, …, Rm}, the set consisting of all resource
• Circular wait: there exists a set {P0, P1, …, P0} of waiting types in the system.
processes such that P0 is waiting for a resource that is held • Request edge – directed edge P1 Rj
by P1, P1 is waiting for a resource that is held by
P2, …, Pn–1 is waiting for a resource that is held by • Assignment edge – directed edge Rj Pi
Pn, and Pn is waiting for a resource that is held by P0.
CSCI 315 Operating Systems Design 7 CSCI 315 Operating Systems Design 8
Example of a Resource
Resource Allocation Graph
Allocation Graph
• Process
• Pi requests instance of Rj
Pi
Rj
• Pi is holding an instance of Rj
Pi
Rj
CSCI 315 Operating Systems Design 9 CSCI 315 Operating Systems Design 10
CSCI 315 Operating Systems Design 11 CSCI 315 Operating Systems Design 12
2
Resource Allocation Graph Resource Allocation Graph
Example 1 Example 2
CSCI 315 Operating Systems Design 13 CSCI 315 Operating Systems Design 14
Basic Facts
• If graph contains no cycles no
deadlock.