Ch8 Deadlock

  • View
    118

  • Download
    0

Embed Size (px)

Text of Ch8 Deadlock

DeadlocksDeadlocks 1

8

Deadlocks 2

2 p1 p2 1 Deadlocks 3

rollback rollback Deadlocks 4

CPU cycles, memory space, I/O devices Ri Wi request - use - release -Deadlocks 5

(Deadlock Characterization)Mutual exclusion: Hold and wait: 1 No preemption: Circular wait:

Deadlocks

6

V E

ResourceAllocation GraphV 2 : P = {P1, P2, , Pn},

request edge Pi Rj

R = {R1, R2, , Rm},

assignment edge Rj Pi

Deadlocks

7

ResourceAllocation Graph ()

pi RjPiRj

Deadlocks

8

ResourceAllocation Graph ()PiRj

pi Rj

Deadlocks

9

Resource Allocation Graph

Deadlocks

10

Allocation Graph

Deadlocks

11

Allocation Graph

Deadlocks

12

Resource Allocation Graph

cycle cycle

Deadlocks

13

3

Deadlocks

14

(Deadlock Prevention)

Mutual Exclusion Hold and Wait (Starvation)

Deadlocks

15

(Deadlock Prevention) ()

No Preemption Deadlocks

16

(Deadlock Prevention) ()

Circular Wait

Deadlocks

17

Deadlock Avoidance

circular-wait resource allocation state

Deadlocks

18

Safe State

safe state

safe state safe sequence Pi ( j

Deadlocks

31

Detection algorithm

Deadlocks

32

wait-for graph Pi Pj Pi Pj cycle n2 operations n Deadlocks 33

Graph Wait-for Graph

Resource-Allocation GraphDeadlocks

Corresponding wait-for graph34

Available: m Allocation: n x m Request: n x m Deadlocks 35

Detection Algorithm

5 P0 P4 3 A (7 ), B (2 ), C (6 )

Deadlocks

36

Detection Algorithm ()AllocationRequest Available A B C A B C A B C P0 0 1 0 0 0 0 000 P1 2 0 0 P3 2 1 1 P4 0 0 2

P2 3 0 3 0 0 0 100

202

Finish[i] = true i

002

Deadlocks

37

DetectionAlgorithm

roll back ) cycle cycle cycle Deadlocks 38

interactive batch

Deadlocks

39

() Rollback Starvation starvation

Deadlocks

40

Deadlocks 41