Home >Common Problem >What is the concept of deadlock?

What is the concept of deadlock?

藏色散人
藏色散人Original
2021-10-15 11:50:5937415browse

Deadlock refers to a blocking phenomenon caused by two or more processes competing for resources or communicating with each other during execution. Without external force, they will not be able to advance. ; At this time, the system is said to be in a deadlock state or the system has produced a deadlock. These processes that are always waiting for each other are called deadlock processes.

What is the concept of deadlock?

The operating environment of this article: windows7 system, DELL G3 computer

What is the concept of deadlock?

Deadlock refers to a blocking phenomenon caused by two or more processes competing for resources or communicating with each other during execution. Without external force, they will all Unable to proceed. At this time, the system is said to be in a deadlock state or the system has a deadlock. These processes that are always waiting for each other are called deadlock processes.

Solution:

After a deadlock has occurred in the system, the occurrence of the deadlock should be detected in time and appropriate measures should be taken to relieve the deadlock.

Deadlock prevention.

This is a simpler and more intuitive method of prevention in advance. The method is to prevent deadlock by setting certain restrictions to destroy one or more of the four necessary conditions for deadlock. Preventing deadlock is an easier to implement method and has been widely used. However, because the constraints imposed are often too strict, system resource utilization and system throughput may be reduced.

Deadlock avoidance.

The system dynamically checks each resource request issued by the process that the system can satisfy, and decides whether to allocate resources based on the check results; if the system may deadlock after allocation, it will not be allocated, otherwise it will be allocated. This is a dynamic strategy to ensure that the system does not enter a deadlock state.

Deadlock detection and release.

Detect first: This method does not require any restrictive measures to be taken in advance, nor does it need to check whether the system has entered an unsafe zone. This method allows the system to deadlock during operation. However, the occurrence of deadlock can be detected in a timely manner through the detection mechanism set up in the system, and the processes and resources related to the deadlock can be accurately determined. Detection methods include timing detection, detection when efficiency is low, detection when the process is waiting, etc.

Then remove the deadlock: take appropriate measures to remove the deadlock that has occurred from the system.

This is a measure matching the detection of deadlock. When a deadlock is detected in the system, the process must be freed from the deadlock state. A common implementation method is to cancel or suspend some processes in order to reclaim some resources, and then allocate these resources to processes that are already in a blocked state to turn them into a ready state to continue running. Deadlock detection and relief measures may enable the system to achieve better resource utilization and throughput, but are also the most difficult to implement.

For more related knowledge, please visit the FAQ column!

The above is the detailed content of What is the concept of deadlock?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn