6.1.2 Consumable resources(2/2 How could deadlock occur when Two processes need to communicate via send/receive messages Process 1 waits to hear from process 2 before sending data Process 2 proceeds after hearing from process 1 Answer Process 1 Process 2 Receive(P2) Receive(P1) Send(p2) Send(P
6.1.2 Consumable Resources(2/2) • How could deadlock occur when • Two processes need to communicate via send/receive messages • Process 1 waits to hear from process 2 before sending data • Process 2 proceeds after hearing from process 1 • Answer: 17
6.1 Principles of Deadlock ·6.1.0 Intro 6.1.1 Reusable resources 6.1.2 Consumable resources 6.1.3 Resource Allocation graphs 6.1. 4 The Conditions for deadlock
6.1 Principles of Deadlock • 6.1.0 Intro • 6.1.1 Reusable Resources • 6.1.2 Consumable Resources • 6.1.3 Resource Allocation Graphs • 6.1.4 The Conditions for Deadlock 18
6.1.3 Resource Allocation Graphs(1/4) Deadlocks can be described using resource allocation graph · Vertices Active processes (Pl, P2,...) · Resources R1,R2,…} Edges a directed edge from pi to r Process Pi requested an instance of resource Rj a directed edge from ri to pi Resource ri has been allocated to process pi Process are circles resources are rectangles
6.1.3 Resource Allocation Graphs(1/4) • Deadlocks can be described using resource allocation graph • Vertices • Active processes {P1, P2, ...} • Resources {R1, R2, ...} • Edges • A directed edge from Pi to Rj • Process Pi requested an instance of resource Rj • A directed edge from Rj to Pi • Resource Rj has been allocated to process Pi • Process are circles, resources are rectangles 19
6.1.3 Resource Allocation Graphs(2/4) Directed graph(有向图) that depicts(表述)a state of the system of resources and processes Reguests Held by Ra P1 R (a)Resouce is requested (b)Resource is held An intance of the resource
6.1.3 Resource Allocation Graphs(2/4) • Directed graph(有向图) that depicts(表述) a state of the system of resources and processes 20 An intance of the resource
6.1.3 Resource Allocation Graphs(3/4) Ra Ra P2 PI P2 Rb Rb (c) Circular wait (d) No deadlock Figure 6.5 Examples of Resource Allocation Graphs 21
6.1.3 Resource Allocation Graphs(3/4) 21