13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Deadlock detection 139Process Holding Outstanding requestA 4 2 B 2 6C4 7Unallocated 2As we saw before, this state could be unsafe (given the claims). However, {A, B, C} isadeadlock-free sequence, so there is no deadlock yet. Again, a slight change can make abig difference. If B should ask for one more resource, this is what we have:Process Holding Outstanding requestA 4 2 B 2 7C 4 7Unallocated 2Now A might finish, yielding 6 free resources, but there is no way to satisfy either B orC, both of which need 7. Processes B and C are deadlocked, but A is not.Deadlock can be detected in such cases by building the resource graph and lookingfor cycles. If one resource class has several equivalent members (like tape drives, whichmight be functionally identical), the simple resource graphs must be improved slightly.We cluster all resources from one class into the same node of the graph. <strong>An</strong> arrow goesfrom any process waiting for a resource to the class node for that resource. If a process iswaiting for several resources, we draw an arrow from the process to each of the appropriateclass nodes. <strong>An</strong> arrow goes from a class node to any process using one of itsresources.A deadlock is no longer signaled by a simple cycle. For example, the generalizedresource graph of Figure 4.10 is an extension of Figure 4.1. There are three tape drivesAtapesCFigure 4.10 A deadlock-free generalized resource graphB

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!