A deadlock is a permanent wait between two or more processes during the execution of a computer program because they occupy the resources needed by each other.

Deadlocks may occur when the following conditions are met

[1] Resources cannot be shared

[2] After a process accepts some resources, it needs to request others.

[3] Resources cannot be forcibly reclaimed

In order to avoid the condition [1] [2], a scheme is designed, called deadlock avoidance.

In this way, “unshareable resources” can be turned into “shareable resources”, requiring the process to request all the resources it needs at once.

In order to avoid conditions [3], a scheme is designed, called “deadlock detection”.

This is done by forcing the recycling of some resources that have already been allocated.

reference

[1] “Introduction to Computer Science” (12th edition), p103-P104

[2] Baidu Encyclopedia, deadlock