How to prevent system process deadlock

Source: Internet
Author: User

The fundamental way to prevent deadlocks is to make one of the 4 necessary conditions that a deadlock does not exist. Here's an analysis of the possibility of breaking these conditions.

Breaking mutually exclusive conditions

Breaking mutually exclusive conditions allows multiple processes to access resources concurrently. Because the inherent nature of most resources must be mutually exclusive access cannot be changed, the prevention of deadlock is not feasible in many cases by destroying this necessary condition. For example, printer resources must be mutually exclusive, otherwise several processes are used at the same time, each process printing a row, the way the output information is clearly not acceptable to the user.

Destruction of possession and waiting conditions

The use of resource static allocation method can destroy this condition, which means that before the process runs, once _ please allocate all the resources it needs to run. If the system has enough resources to allocate to a process, it assigns the required resources to the process at once, so that no resource requests are made during the process, making the wait condition not valid. If one of the resource requirements is not met at the time of allocation, the other resources required by the process are not assigned to the process, thereby preventing the process from taking up any resources during the wait, destroying the occupancy condition, and thus avoiding the deadlock.

The method is simple and easy to implement, however, due to the full use of the required resources during the process, some of the resources that have been used for a short period of time are occupied for a long time, which can seriously affect the full utilization of the system resources, resulting in lower resource utilization and the same inch affecting the process of not getting all the resources.

Destroy the condition of not being deprived

The use of a deprivation control method can destroy the condition by enabling a process that has maintained certain resources, since the new resource requirements are currently not met, it must first temporarily release all the resources that have been maintained (a kind of deprivation), and then go to wait, and then together to the system to put towel please, this can also prevent deadlock. This approach is relatively difficult to achieve, in order to protect the process to automatically discard the resources of the site and subsequent recovery, the need to pay a high price, and this method is only applicable to the processor and memory resources, other resources, this method is not suitable for use.

Destroy the loop wait condition

This condition can be destroyed by using the resource order distribution method. The basic idea of this method of distribution is to divide the whole resources of the system into multiple levels, once a process gets a resource from a layer, it can only ask for a higher level of resources; When a process releases a resource from a layer, it must first release the higher level of resources it occupies; When a process obtains a resource from a layer, It wants to apply for another resource in that layer, and it must first release the resources that have been in that layer. Alternatively, the order in which the processes release resources is in the reverse order of the resources requested in. This prevents the cycle-waiting phenomenon from occurring and therefore does not result in deadlocks. The problem that should be paid special attention to in using this method is the arrangement of the level of resources. In general, the more general resources that are often used in the processes are arranged at a lower level, with important and relatively scarce resources placed at a higher level in order to maximize the use of resources. Compared with the methods described earlier, the method has a significant improvement in resource utilization and system throughput. But there are some flaws.

(1) Low-level resources must be requested before the process requests the allocation of Gao resources, which can be wasted on idle waiting for low-level resources that are temporarily unused.

(2) The level of resources of various types of equipment, once set, can not be arbitrarily changed, which limits the increase of new types of equipment.

(3) The level of each resource is set in the order in which most processes use resources. Resources can be used effectively in the process of using resources to flash with this level, otherwise, the waste of resources will still exist.

Note : More wonderful tutorials Please pay attention to the triple computer tutorial section, triple Computer office group: 189034526 welcome you to join

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.