Causes of deadlock and four necessary conditions

The main reasons for the deadlock are:
(1) Because of insufficient system resources.
(2) The order in which the processes are running and advancing is not appropriate.
(3) Improper allocation of resources, etc.
If the system resources are sufficient and the resource requests of the process can be satisfied, the possibility of deadlock is very low, otherwise it
will fall into deadlock due to competition for limited resources. Second, processes run in different order and speed, which may also cause deadlocks.
There are four necessary conditions for deadlock:
(1) Mutual exclusion condition: A resource can only be used by one process at a time.
(2) Request and hold conditions: When a process is blocked due to requesting resources, it will hold on to the obtained resources.
(3) No deprivation condition: The resources that the process has obtained cannot be forcibly deprived before the end of the use.
(4) Circular waiting condition: A cyclic waiting resource relationship is formed between several processes.
These four conditions are necessary conditions for deadlock . As long as a deadlock occurs in the system, these conditions must be established, and as long as
one of is not satisfied, deadlock will not occur.
Removal and prevention of deadlocks:
By understanding the causes of deadlocks, especially the four necessary conditions for deadlocks, you can avoid, prevent and
release deadlocks to the greatest extent possible. Therefore, in system design, process scheduling, etc., pay attention to how to prevent these four necessary conditions from being established, and how to
determine a reasonable allocation algorithm for resources to prevent processes from permanently occupying system resources. Also, prevent processes
from consuming resources while they are in a wait state. Therefore, reasonable planning should be given to the allocation of resources.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326355799&siteId=291194637