Chapter_5_-_Deadlocks - Chapter 5 - Deadlocks Further...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Deadlock Handling 1 Chapter 5 - Deadlocks Further Reading: Stallings Chapter 6 Silberschatz Chapter 7 Tanenbaum Chapter 6
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Deadlock Handling 2 Deadlock definition Deadlock: •A s e t o f blocked processes each waiting for an event that only another process in the set can cause . Example of a possible event: • resource to become available
Background image of page 2
Deadlock Handling 3 Bridge Crossing Example Traffic only in one direction. Each “half” of the bridge can be viewed as a resource. •I f a deadlock occurs , it can be resolved if one car backs up ( preempt resources and rollback ). – several cars may have to be backed up – starvation is possible.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Deadlock Handling 4 Examples of (potential) Deadlocks in Resource Allocation semaphores AandB, initialized to 1 (or: system has 2 tape drives ; P 0 and P 1 each hold one tape drive and each needs another one) P 0 P 1 wait (A); wait(B); wait (B); wait(A) 200Kbytes memory-space is available P 0 P 1 request (80Kbytes); …… request (70Kbytes); deadlock might occur if both processes proceed to the second request message -passing with blocking receive P 0 P 1 receive(P 1 ); 0 ); send(P , M1); 1 , M0);
Background image of page 4
Deadlock Handling 5 Conditions for Deadlock Mutual exclusion : only one process at a time can use a resource. Hold and wait : a process holding some resource can request additional resources and wait for them if they are held by other processes. No preemption : a resource can only be released voluntarily by the process holding it, after that process has completed its task. Circular wai t : there exists a circular chain of 2 or more blocked processes, each waiting for a resource held by the next process in the chain [Coffman-et al 1971] 4 conditions must hold simultaneously for a deadlock to occur:
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Deadlock Handling 6 Resource Allocation & Handling of Deadlocks Require processes to give info in advance about the (max) resources they will require Schedule processes in a way that avoids deadlock. deadlock avoidance: deadlock is possible, but OS uses advance info to avoid it Allow a deadlock state and then recover Structurally restrict the way in which processes request resources deadlock prevention: deadlock is not possible Ignore the problem and pretend that deadlocks never occur in the system (can be a “solution” sometimes?!…)
Background image of page 6
Deadlock Handling 7 Resource Allocation: System Model Resource types R 1 , R 2 , . . ., R m – e.g. CPU, memory space, I/O devices, files – each resource type i has W i instances. Each process utilizes a resource as follows (as discussed for the dining philosophers): – request (hungry) – use (eat) –r e l e a s e
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Deadlock Handling 8 Resource Allocation Graph Resource-Allocation Graph A set of vertices V and a set of edges E. – V is partitioned into two sets: P= {P 1 , P 2 , …, P n } the set of processes R= {R 1 , R 2 , …, R m } the set of resource types request edge : P i R j assignment edge : R P i
Background image of page 8
Deadlock Handling 9 Example of a Resource Allocation Graph With A Deadlock
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Deadlock Handling 10 Resource Allocation Graph With A cycle but no Deadlock
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 34

Chapter_5_-_Deadlocks - Chapter 5 - Deadlocks Further...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online