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.

Perspective 143used to make sure that no deadlocks arise from using these resources. We will return tothis point in Chapter 8, where we discuss mechanisms for achieving exclusive access.Second, deadlock is an unacceptable situation only if everyone is infinitely patient.In interactive environments, the resource manager need not recover from or even detectdeadlocks because the user will eventually get bored waiting for an answer and willmanually terminate the process.The service call we described for requesting resources could be enhanced byincluding a timeout parameter. If the resource manager cannot or will not honor therequest within the time specified by this parameter, it unblocks the calling process andgives it a failure indication. The process could try again, try a different request, back outof whatever action it is trying to perform, or terminate.Some authors distinguish deadlock prevention from avoidance. Preventionincludes any method that negates one of the following three conditions that lead todeadlock.Resources may not be shared. One can sometimes get the effect of sharing an otherwisenon-sharable device by buffering all output to that device (in parallel) andthen serializing the output of those buffers. Buffering can therefore be used as aprevention method, but deadlock can still arise over the use of the buffers themselves.Resources may be requested while others are already being held. As we have seen,the one-shot method prohibits such action, and is therefore a prevention method.The hierarchical method prevents such requests within a level; by induction, itprevents circular wait across levels as well.Resources may not be preempted. Under batch multiprogramming, some jobs mayallow cancellation and restarting. However, jobs that have made changes to filesare unlikely to be restartable.Avoidance, on the other hand, includes methods like the banker’s algorithm that takeadvantage of advance knowledge (such as maximum claims). That advance knowledgeallows them more freedom to navigate the progress diagram and still avoid dangerousregions.The conservative-liberal metaphor helps in rating various policies that we haveseen. Liberal policies have a greater potential for parallelism and throughput becausethey allow more flexible navigation of the progress diagram, but they have an equalpotential for deadlock and starvation. The advance-claim algorithm provides a reasonablyliberal method that is still conservative enough to prevent deadlock. To preventstarvation as well, other conservative steps must be taken, such as banning new arrivalsor concentrating resources on particular processes. Overly conservative methods likeone-shot allocation remove all worries about deadlock and starvation, but the cost issevere reduction of concurrency.Although we have devoted a significant amount of attention to the advance-claimalgorithm, it is mostly interesting in the theoretical, not the practical, sense. As wepointed out, many applications are unable to compute reasonable claims before they startworking; they only discover what they will need once they have made some progress.Furthermore, resources can disappear suddenly if the hardware malfunctions. Therefore,most operating systems don’t implement the advance-claim algorithm. It is much morecommon to grant resources to processes following the most liberal policy imaginable. Ifthis policy leads to deadlock, the deadlock is detected (either by the resource manager or

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

Saved successfully!

Ooh no, something went wrong!