S8 - deadlocks.ppt - Chapter 7 Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance

S8 - deadlocks.ppt - Chapter 7 Deadlocks System Model...

This preview shows page 1 - 7 out of 45 pages.

Chapter 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock
Image of page 1
The Deadlock Problem In a multiprogramming environment, several processes may compete for a number of resources. A process requests resources; if the resurces are not available at that time, the process enters a waiting state. Sometimes, a waiting process is never again able to change state, because the resources it has requested are held by other waiting processes. This situation is called a deadlock . A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set. Example System has 2 CD RW drives. P 1 and P 2 each holds one CD RW drive and each needs another one. Example semaphores A and B representing CD RW drives are initialized to 1 P 0 P 1 wait (A); wait(B) wait (B); wait(A)
Image of page 2
Bridge Crossing Example Traffic only in one direction. Each section of a bridge can be viewed as a resource. If a deadlock occurs, it can be resolved if one car backs up (preempt resources and rollback). Several cars may have to be backed up if a deadlock occurs. Starvation is possible.
Image of page 3
System Model System consists of a finite number of resources Resource types R 1 , R 2 , . . ., R m CPU cycles, memory space, I/O devices, files, semaphores Each resource type R i has W i instances. If a system has two CPU’s, then the resource type CPU has two instances. Each process utilizes a resource as follows: request use Release A process cannot request more than the total number of resources available in the system
Image of page 4
Deadlock Characterization Mutual exclusion : At least one of the resources is in a non-sharable mode (two processes cannot use a resource at the same time), where only one process at a time can use that resource(e.g. printer). If another process request that resource, the requesting process must be delayed untill the resource has been released. Hold and wait: There must be at least one process holding at least one resource and waiting to acquire additional resources currently being hold by other processes. No preemption: No resource can be preempted before the holding process completes its task with that resource. Circular wait: there exists a set { P 0 , P 1 , …, P 0 } of waiting processes such that P 0 is waiting for a resource that is held by P 1 , P 1 is waiting for a resource that is held by P 2 , P n –1 is waiting for a resource that is held by P n , and P n is waiting for a resource that is held by P 0 . Deadlock can arise if four conditions hold simultaneously .
Image of page 5
Resource-Allocation Graph V is partitioned into two types: P = { P 1 , P 2 , …, P n }, the set consisting of all the processes in the system.
Image of page 6
Image of page 7

You've reached the end of your free preview.

Want to read all 45 pages?

  • Fall '19
  •  Example

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture