7. deadlocks - Deadlocks The Deadlock Problem • A set of...

Info icon This preview shows pages 1–15. Sign up to view the full content.

View Full Document Right Arrow Icon
Deadlocks
Image of page 1

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

View Full Document Right Arrow Icon
The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set Example1 System has 2 tape drives P 1 and P 2 each hold one tape drive and each needs another one Example2 Semaphores A and B , 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

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

View Full Document Right Arrow Icon
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 Each process utilizzing a resource: 1. Requests 2. Uses the resource 3. Releases the resource Request and release of resources is done through system calls
Image of page 4
Deadlock Characterization Mutual exclusion: only one process at a time can use a resource(i.e. resource is non-sharable). Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes. No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task. Circular wait: there exists a set { P 0 , P 1 , …, P n } 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

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

View Full Document Right Arrow Icon
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. R = { R 1 , R 2 , …, R m }, the set consisting of all resource types in the system Request edge – directed edge P i R j Assignment edge – directed edge R j P i A set of vertices  V  and a set of edges  E .
Image of page 6
Resource-Allocation Graph (Cont.) Process Resource Type with 4 instances P i requests instance of R j P i is holding an instance of R j P i P i R j R j
Image of page 7

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

View Full Document Right Arrow Icon
Example of a Resource Allocation Graph
Image of page 8
Resource Allocation Graph With A Deadlock
Image of page 9

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

View Full Document Right Arrow Icon
Resource Allocation Graph With A Cycle But No Deadlock
Image of page 10
Basic Facts If graph contains no cycles no deadlock. If graph contains a cycle If only one instance per resource type, then deadlock If several instances per resource type, possibility of deadlock
Image of page 11

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

View Full Document Right Arrow Icon
Methods for Handling Deadlocks Ensure that the system will never enter a deadlock state. (Prevention or Avoidance) Allow the system to enter a deadlock state and then recover.
Image of page 12
Deadlock Characterization Mutual exclusion Hold and wait No preemption Circular wait Deadlock can arise if four conditions hold simultaneously.
Image of page 13

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

View Full Document Right Arrow Icon
Deadlock Prevention Mutual exclusion not required for sharable resources; Must hold for non-sharable resources.
Image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern