The perfect way for system processes to no longer deadlock

  

If there are multiple programs running on our computer at the same time, there will be competition for certain data resources, and if the resources are not enough, they will enter the waiting state. If the requested resource is occupied by other waiting processes, then the waiting process may be in a waiting state forever and cannot change the state. This is a so-called system process deadlock. So, is there any way to make the system process not deadlock?

In fact, the fundamental way to want the system to not deadlock is to eliminate the four necessary conditions for deadlock, let’s analyze it together. How to destroy these conditions.

Destroying Mutex Conditions

Destroying a mutex condition allows multiple processes to access resources at the same time. Since the inherent characteristics of the exclusive access of most resources cannot be changed, the prevention of deadlocks does not work in many cases by destroying this necessary condition. For example, printer resources must be used interchangeably. Otherwise, several processes are used at the same time. Each process prints one line. This way of outputting information is obviously not acceptable to the user.

Destroying Possession and Waiting Conditions

This condition can be broken by using the static resource allocation method, which means that all resources required for its operation are allocated at a time before the process runs. . If the system has enough resources to allocate to a process, it allocates its required resources to the process at one time, so that no resource requests are made during the running of the process, so that the waiting condition is not established. If there is a resource requirement that cannot be satisfied when the allocation is made, other resources required by the process are not allocated to the process first, thereby avoiding that the process occupies any resources during the waiting period and destroys the occupation condition, thereby avoiding the occurrence of deadlock.

This method is simple and easy to implement. However, due to the full occupation of the required resources during the running of the process, some resources with short usage time are occupied for a long time, which will seriously affect the full utilization of system resources. As a result, resource utilization is reduced, and peers also affect the delay in the operation of processes that do not have access to all resources.

Destruction and deprivation conditions

Destructive control can destroy this condition by making a process that has already maintained certain resources, which are currently not met due to new resource requirements. It must temporarily release all the resources (a deprivation) that it maintains, and then wait, and then bring the towel to the system together, which will also prevent deadlock. This method is relatively difficult to implement. In order to protect the process from automatically abandoning the site of the resource and later recovering it, it costs a high price, and this method is only applicable to the processor and memory resources. For other resources, this method should not be used. .

Breaking the loop wait condition

Using the resource order allocation method can break the condition. The basic idea of ​​this allocation method is to divide all the resources of the system into multiple levels. After a process gets a resource of a certain layer, it can only _ ask for a higher layer of resources; when a process wants to release a layer When a resource is used, it must first release the higher-level resources it occupies; when a process acquires a resource of a certain layer, it wants to apply for another resource in the layer, and it must first be released in the layer. Possession of resources. In other words, the order in which the process releases resources is in the reverse order of the resources requested. This prevents loop waits from occurring, so deadlocks do not occur. A particular concern with this approach is the arrangement of the resources at the level. Under normal circumstances, the more common resources often used by each process are arranged at a lower level, and important and relatively scarce resources are arranged at a higher level in order to maximize the use of resources. . Compared with the method described above, this method has significant improvements in resource utilization and system throughput. But there are also some flaws.

(1) Low-level resources must be applied in advance before the process requests the allocation of resources at the level. This is a waste of idle waiting for low-level resources that are not needed for the time being.

(2) Once the resource levels of various types of equipment are set, they cannot be changed at will, 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. For the process of resource usage and flashing at this level, resources can be effectively utilized. Otherwise, the waste of resources will still exist.

If a deadlock occurs, the process can never complete, and it prevents the use of system resources and prevents other jobs from starting execution. Therefore, it is so important that the system process no longer has a deadlock, and it needs to attract our attention.

Copyright © Windows knowledge All Rights Reserved