Preventive strategies of deadlock deadlock

1. The destruction of mutually exclusive conditions

Mutually exclusive conditions : only competition for resources will have exclusive use of the results in a deadlock.

If the transformation can only be mutually exclusive use of resources to allow shared use, the system will not enter into a deadlock state. For example: SPOOLING technology . The operating system may employ techniques SPOOLing transformed into the exclusive device logically shared device. For example, with SPOOLing technology will transform the printer as a shared device.
Here Insert Picture Description
Here Insert Picture Description

The disadvantage of this strategy: not all resources can be transformed into a shared use of resources. And in order to secure the system, many places have to protect this mutually exclusive. Therefore, a lot of damage when they are not mutually exclusive conditions.

2. The destruction of the inalienable conditions

Inalienable condition : Resources obtained before the process is not used, can not be forcibly taken away by other processes, can only take the initiative to release.

Undermine the inalienable condition:
Option One: When a process requests new resources are not met, it must immediately release all resources held until later to re-apply when needed. In other words, even if some of the resources have not been used up, need to take the initiative to release, thereby undermining the inalienable condition.
Option Two: When a process needs resources to be occupied by other processes sometimes be assisted by the operating system, will want to deprive the resource. In this way - - like the need to consider the priority of each process (for example: preemptive scheduling mode, it is to deprive the processor resources to a higher priority process use)

The disadvantage of this strategy:
1. to implement more complex.
2. Release acquired resources may result in failure of the previous stage work. Therefore, this method generally apply only to easy to save and restore the state of resources, such as the CPU.
3. repeated application and release resources will increase overhead and reduce system throughput.
4. If using a program, means that as long as the temporary lack of a resource, prior to obtaining those resources would need to give up, later re-apply. If such a situation has occurred, the process will lead to hunger.

3. destruction request and holding conditions

Request and keeping conditions: the process has been maintained for at least one resource, but proposed a new resource request, the resource has been occupied by another process, this time requesting process is blocked, but on their existing resources to keep hold.

Static allocation methods can be used, which is the process before running applications at once all the resources it needs, before its resources are not met, do not let it put into operation. Once in operation, these resources have been owned by it all, the process will not request any other resource of.

The strategy is simple to implement, but there are significant disadvantages:
Some resources may require only a very short time, so they have all the resources has maintained throughout the run if the process, it will cause a serious waste of resources, resource utilization is very low . In addition, the policy may also lead to some progress hunger.

Here Insert Picture Description

4. destruction cycle wait condition

Loop wait condition: there is a waiting loop process resource chain, the chain of resources acquired each process simultaneously processes the next request.

Can be sequential resource allocation method . First, the system of numbering resources, requires that each process must request a resource, similar resources are numbered sequentially increasing (ie, the same number of resources) a complete application.

Principle Analysis: A process has occupied only a small number of resources when, to be eligible for a greater number of resources. This rule, already holds a large number of resources can not reverse the process to apply for funding for a small number back, so you will not have to wait for the cycle phenomenon.

At any one time, there is always a process has the largest number of resources, resources that after this process is bound to apply unimpeded. Therefore, it is impossible a deadlock all processes are blocked.

The disadvantage of this strategy:
1. inconvenient to add new equipment, because it may need to re-assign all numbers:
the order of the actual use of resources 2. The process may be inconsistent and numbered in ascending order, will lead to a waste of resources:
3 must apply for the required order resources, user programming of trouble.

5. Summary

Here Insert Picture Description

Published 168 original articles · won praise 1 · views 2968

Guess you like

Origin blog.csdn.net/yrx420909/article/details/104459772