Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSI 400/500 Operating Systems Spring 2009 Lecture #17 –Deadlocks Wednesday, April 15 th.

Similar presentations


Presentation on theme: "CSI 400/500 Operating Systems Spring 2009 Lecture #17 –Deadlocks Wednesday, April 15 th."— Presentation transcript:

1 CSI 400/500 Operating Systems Spring 2009 Lecture #17 –Deadlocks Wednesday, April 15 th

2 2 Deadlock is... Permanent blocking of at least two processes competing for system resources One process waiting on release of resource held by another, who is waiting for different resource held by waiting process

3 3 Resource Types Reusable Process holds resource and then releases for later reuse by other processes Process holds resource and then releases for later reuse by other processes Examples: buffer, processors, memory, data devices Examples: buffer, processors, memory, data devicesConsumable Process creates and destroys resource Process creates and destroys resource Example: message blocks Example: message blocks

4 4 Conditions for Deadlock Mutual Exclusivity : only one process holds resource at a time Hold and wait : processes allowed to hold resources while waiting Non-preemptive processes Circular wait : processes in wait hold resources requested by hold resources requested byothers

5 5 Simple Solution Each process releases resource before requesting another Not always possible Data integrity of referenced Data integrity of referencedresource Dependent data or resources Dependent data or resources

6 6 Determining Deadlock Likelihood Resource Allocation Graph Shows processes, resources, and who holds or requests resources. Shows processes, resources, and who holds or requests resources. Rectangle is resource, circle is process Arrow from resource to process denotes hold Arrow from resource to process denotes hold Arrow from process to resource denotes request Arrow from process to resource denotes request  

7 7 Relieving Deadlock at Resource Level Multiple images Some resources (like database tables) allow multiple images, so that multiple processes can use it Some resources (like database tables) allow multiple images, so that multiple processes can use it Only works for read access Only works for read access Multiple read locks possible, only one write lock Demonstrated on Resource Allocation Graph by multiple dots Demonstrated on Resource Allocation Graph by multiple dots Read often denoted by solid arrowhead and dot, while write with open Read often denoted by solid arrowhead and dot, while write with open

8 8 Preventing Deadlock Total request Process requests all resources needed before proceeding Process requests all resources needed before proceeding Prevents Hold and Wait condition Prevents Hold and Wait condition Could starve resource heavy processes Could starve resource heavy processes

9 9 Preventing Deadlock, cont Single Write Lock Allow a process to hold only one Allow a process to hold only one write lock Prevents Hold and Wait Prevents Hold and Wait Could cause excessive wait if process holding write lock holds it for long time Could cause excessive wait if process holding write lock holds it for long timePreemption Insisting all process can be preempted Insisting all process can be preempted Only practical for resources easily saved and restored, like processors Only practical for resources easily saved and restored, like processors

10 10 Preventing Deadlock, cont Resource Ordering Resources of similar type must be allocated in order Resources of similar type must be allocated in order Release all existing locks to cycle back to beginning Release all existing locks to cycle back to beginning Prevents circular wait Prevents circular wait

11 11 Deadlock Avoidance Doesn’t restrict processes or resources Analyzes situations to prevent the simultaneous occurrence of all conditions Two methods: Process Denial Process Denial Resource Allocation Denial Resource Allocation Denial

12 12 Process Denial Works with resource claims Processes have maximum resource claim No process granted resources that exceed original claim No process set to Ready if their maximum resource claim + resource claim of processes in system exceeds maximum resource allocation

13 13 Pitfalls Assumes processes will request maximum resources at same time Prevents initiation of many processes

14 14 Resource Allocation Denial Deny resources to processes who could cause deadlock Expands Allocation and Claim numbers from Process Denial, but allows processes to begin Works with Remaining and Available resource vectors Processes through safe state until unsafe state detected

15 15 Deadlock Detection Check each resource request Demands that a request set maintained Request set lists processes with outstanding requests for resources When circular wait discovered, determine deadlocked resource and suspend active process

16 16 Integrated Strategy Group resources into classes Use linear ordering Maintain at least request and allocation matrices, if not maximum claim matrix


Download ppt "CSI 400/500 Operating Systems Spring 2009 Lecture #17 –Deadlocks Wednesday, April 15 th."

Similar presentations


Ads by Google