07_deadlocks

07_deadlocks - Chapter 7: Deadlocks Chapter Chapter 7:...

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

View Full Document Right Arrow Icon
Chapter 7: Deadlocks Chapter 7: Deadlocks
Background image of page 1

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

View Full DocumentRight Arrow Icon
7.2 Modified by Bo Li ©2009 Operating System Concepts Chapter 7: Deadlocks Chapter 7: Deadlocks ± The Deadlock Problem ± System Model ± Deadlock Characterization ± Methods for Handling Deadlocks ± Deadlock Prevention ± Deadlock Avoidance ± Deadlock Detection ± Recovery from Deadlock
Background image of page 2
7.3 Modified by Bo Li ©2009 Operating System Concepts The Deadlock Problem The Deadlock Problem ± A set of blocked processes each holding a resource while waiting to acquire a resource held by another process in the set. ± Example 1 z A system has 2 tape drives. z P 1 and P 2 each hold one tape drive and each needs another one. ± Example 2 z semaphores A and B , initialized to 1 P 0 P 1 wait (A); wait(B) wait (B); wait(A)
Background image of page 3

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

View Full DocumentRight Arrow Icon
7.4 Modified by Bo Li ©2009 Operating System Concepts Bridge Crossing Example Bridge Crossing Example ± Traffic only in one direction. ± Each section of a bridge can be viewed as a resource z Traffic only in one direction at a time ± If a deadlock occurs, it can be resolved if one car backs up (preempt resources and rollback). z Several cars may have to be backed up if a deadlock occurs . ± Starvation is possible z Only cars passing by from one direction
Background image of page 4
7.5 Modified by Bo Li ©2009 Operating System Concepts Dining Philosopher Problem Dining Philosopher Problem - - Revisit Revisit ± Five chopsticks/Five Philosophers z Free-for all: each philosopher will grab any one they can z Need two chopsticks to eat ± What if all grab one at same time? z Deadlock! ± How to fix deadlock? z Make one of them give up a chopstick (Hah!) z Eventually everyone will get chance to eat ± How to prevent deadlock? z Either grab two chopsticks or no chopstick?
Background image of page 5

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

View Full DocumentRight Arrow Icon
7.6 Modified by Bo Li ©2009 Operating System Concepts The System Model The System Model ± Resource types R 1 , R 2 , . . ., R m CPU cycles, memory space, I/O devices ± Each resource type R i has W i instances. ± Two types of resources: z Preemptable – can take it away, e.g., CPU z Non-preemptable – must leave it with the thread, e.g., disk space ± Resources may require exclusive access or may be sharable z Read-only files are typically sharable z Printers are not sharable during time of printing ± Each process utilizes a resource as follows: z request z use z release
Background image of page 6
7.7 Modified by Bo Li ©2009 Operating System Concepts Deadlock Characterization Deadlock Characterization ± Mutual exclusion z only one process at a time can use a resource. ± Hold and wait z a process holding at least one resource is waiting to acquire additional resources held by other processes. ± No preemption z a resource can be released only voluntarily by the process holding it, after that process has completed its task. ± Circular wait
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 32

07_deadlocks - Chapter 7: Deadlocks Chapter Chapter 7:...

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

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