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.

138 Resource Deadlock Chapter 4most liberal policy that is guaranteed not to deadlock. One cost of this achievement isthe requirement that processes enter claims, which may be unnatural. For example, aprocess that needs to modify a number of files needs to exclude other processes, but itmight not know which files must be modified until it has read a significant amount of datafrom many files. A second cost of the advance-claim algorithm is the time and spaceneeded for finding a safe sequence.More complex methods exist that lead still closer to our goal. They require stillmore prior information about what the processes will need. For example, if we know theexact order in which each process will request and release resources, we can organize amore liberal schedule. The necessary calculation, however, is quite time-consuming.7 DEADLOCK DETECTIONThe methods described so far can be characterized as policies for deadlock prevention.If, however, we are willing to allow deadlocks, we must be able to discover them whenthey occur. We call this strategy deadlock detection. A method similar to the advanceclaimalgorithm can be used to check for a deadlock-free sequence when the current allocationstate is unsafe. We say that a state is deadlock-free if there is a sequence ofprocesses, called a deadlock-free sequence, such that the following three conditions aremet.(1) The first process in the sequence might finish because there are enough freeresources to fulfill its current outstanding request (what it has actually asked for)even if there are not enough to satisfy its entire claim (what it may potentially askfor).(2) The second process in the sequence might finish if the first finishes and releaseseverything it now has, because adding what the first has to the free resources cansatisfy the entire outstanding request of the second process.(3) The ith process might finish if all the previous processes do because the sum ofall their resources and the currently free resources can satisfy the entire outstandingrequest of the ith process.A deadlock-free state has no current deadlock because the chain of waiting processes isnot cyclic. However, if it is unsafe, an unlucky set of requests can turn it into adeadlocked state. Let us continue the previous unsafe example, adding a column for theoutstanding request, that is, the request that has been made that we have not yet decidedto honor. (We are either at the point of deciding whether to honor it or we have placedthe requesting process in a resource-wait list.) We no longer need the Claims column,since we are not using the advance-claim algorithm.

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

Saved successfully!

Ooh no, something went wrong!