Академический Документы
Профессиональный Документы
Культура Документы
Lesson 6: Deadlocks
AIM
The simplest approach is the ostrich algorithm: stick your head in the sand
and pretend there is no problem at all.
Different people react to this strategy in different ways. Mathematicians find
it totally unacceptable and say that deadlocks must be prevented at all costs.
Engineers ask how often the problem is expected, how often the system
crashes for other reasons, and how serious a deadlock is. If deadlocks occur
on the average once every 50 years, but system crashes due to hardware
failures, compiler errors, and operating system bugs occur once a month,
most engineers would not be willing to pay a large penalty in performance or
convenience to eliminate deadlocks.
Deadlock Detection and Recovery
A second technique is detection and recovery. When this technique is
used, the system does not do anything except monitor the requests and
releases of resources.
Every time a resource is requested or released, the resource graph is
updated, and a check is made to see if any cycles exist, If a cycle
exists, one of the processes in the cycle is killed.
If this does not break the deadlock, another process is killed, and so on
until the cycle is broken.
A somewhat cruder method is to not even maintain the resource graph
but instead periodically check to see if there are any processes that
have been continuously blocked for more than say, 1 hour.
Such processes are then killed. Detection and recovery is the strategy
often used on large mainframe computers, especially batch systems in
which killing a process and then restarting it is usually acceptable.
Care must be taken to restore any modified files to their original state,
however, and undo any other side effects that may have occurred.
Deadlock Prevention