Sie sind auf Seite 1von 13

Strategies for Handling Deadlocks

Request and releases are received in an unpredictable order which makes it very difficult to design a foolproof preventative policy for deadlocks. The operating system uses one of three methods to deal with deadlock.

Strategies for Handling Deadlocks Continued


Prevention Avoidance Detection With prevention, the operating system must remove one of the four necessary conditions, the is made difficult by the fact that the same condition cant be eliminated from every resource.

Mutual exclusion continued


This however can also become another form of deadlock. (deadlocks in spooling)

Resource holding
Resource holding, where a job holds on to one resource while waiting for another one thats not yet available, could be sidestepped by forcing each job to request, at creation time, every resource it will need to run to completion. But although it works well with batch environments it doesn't work so well with interactive environments

NO Pre-emption
no pre-emption: one of four conditions for deadlock in which a process is allowed to hold on to resources while it is waiting for other resources to finish execution. Can be bypassed by allowing the operating system to deallocate resources from jobs

Circular wait
circular wait: one of four conditions for deadlock through which each process involved is waiting for a resource being held by another; each process is blocked and cant continue, resulting in deadlock. Can be bypassed if the operating can prevent the formation of a circle.

This scheme of hierarchical ordering removes the possibility of a circular wait and therefore guarantees the removal of deadlocks. It doesnt require that jobs state their maximum needs in advance, but it does require that the jobs anticipate the order in which they will request resources.

Recovery
Once detected , a deadlock must be fixed and the system returned to normal as soon as possible. There are several recovery methods but the all require one job to be stopped, this will free the system. The decoy can then be restarted.

Recovery methods
Simple. Terminate every active job and restart the system. Terminate only the jobs in deadlock and ask the users to resubmit them Identify jobs that are involved in the deadlock and end them one by one, checking each time to see if the deadlock has ended. This way the remaining jobs can complete their processing and the halted jobs can be restarted.

The fourth method requires that the job can save its location (how far it has reached in its processing). that way should the job be halted it can be resumed from its last save point rather to start from the beginning.

The fifth method uses a job that is not in deadlock. The selected job processing is saved, paused and the job is moved into the deadlocked process and resumed thereby breaking deadlock. The sixth method stops new jobs from entering the system, allows no deadlocked jobs to finish, then gives its resources to the deadlocked jobs so that the have enough resources to run to completion.

The victim
Factors to be considered when choosing the victim. 1. The importance of the job 2. The job duration 3. The affect it has on other jobs also jobs that are modifying data shouldn't be selected for termination because the consistence and the validity of the database would be jeopardized.

Das könnte Ihnen auch gefallen