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.

Starvation 141needs to check for deadlock only at this time. A reasonable alternative, taken by VMS, isto start a timer for 10 seconds (or however long is specified by the deadlock-wait parameter)whenever a request blocks. If the request is still blocked when the timer expires, anattempt is made to detect deadlock. The goal of the attempt is to remove the blockedprocess that triggered the detection episode from the resource graph. If that process canbe removed, it is not necessary to continue and remove the others; there is no deadlockinvolving that process.8 DEADLOCK RECOVERYWhen a deadlock occurs, one of the processes participating in the deadlock must be terminatedfor the good of the community. A policy that chooses a victim process is calleda method of deadlock recovery. Terminating a process might injure data, as we haveseen. A process currently modifying shared data should be able to warn the resourcemanager not to terminate it to recover from deadlock. If data consistency presents noproblems, the terminated victim might be restarted later. The designers of databasemanagement packages have developed very sophisticated mechanisms to allow databasetransactions to be aborted in such a way that restart is always possible. We will discusssome of those mechanisms in Chapter 6.To select a victim process, the resource manager could take into account the externalpriority of the process and how expensive it will be to restart it. One good measure isthe amount of computation the process has already performed. The larger this amount,the more expensive it is to restart the process and get it to its present state. Also, onewould hope that processes that have consumed large amounts of computation are almostfinished.9 STARVATIONOur discussion has concentrated on deadlock, which is due to overly liberal policies forallocation of resources. Starvation, in contrast, is the result of overly liberal policies forreassigning resources once they are returned. When resources are freed, they can beapplied to any process waiting for them in the resource-wait list. (The short-termscheduler should most likely not switch to the waiting process but should continue withthe releasing process, in accord with the Hysteresis Principle.) Not all policies for applyingthose resources prevent starvation.For example, consider a situation with one resource class. A straightforward policyis to apply all released resources to the first-blocked process. However, the blockedprocess may be the last in all possible safe sequences for the current allocation state. Wecan’t unblock it, or the state becomes unsafe. We can’t apply the resources to other jobsbecause they were not blocked first. Hence this policy does not work at all.

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

Saved successfully!

Ooh no, something went wrong!