Several processes are waiting endlessly for other processes to release occupied resources due to competition for resources.
There is a contradiction between the limited resources in the computer system and the many processes requesting the allocation of resources. When the total number of resources required by several processes is greater than the number of resources that the system can provide, the process will preempt resources. If the resources preempted by the process are not properly managed or allocated, deadlock will occur.(Recommended learning:web front-end video tutorial)
Deadlock refers to the fact that two or more processes are competing for resources or communicating with each other during execution. It is a kind of blocking phenomenon. Without external force, they will not be able to move forward. 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.
Generation conditions
Although a deadlock may occur during the running process, certain conditions must be met for a deadlock to occur. The following four necessary conditions are required.
1) Mutual exclusion condition: refers to the exclusive use of allocated resources by a process, that is, a certain resource is only occupied by one process within a period of time. If there are other processes requesting resources at this time, the requester can only wait until the process occupying the resources is used up and released.
2) Request and hold conditions: It means that the process has held at least one resource, but has made a new resource request, and the resource has been occupied by other processes. At this time, the requesting process is blocked, but it has already requested the resource. Other resources obtained remain unchanged.
3) Non-deprivation condition: refers to the resource that the process has obtained. It cannot be deprived before it is used up, and can only be released by itself when it is used up.
4) Loop waiting condition: When a deadlock occurs, there must be a process-a circular chain of resources, that is, P0 in the process set {P0, P1, P2,···,Pn} Waiting for a resource occupied by P1; P1 is waiting for a resource occupied by P2,..., Pn is waiting for a resource occupied by P0.
Cause
Competition for resources causes process deadlock
When resources such as printers are shared by multiple processes in the system , public queues, etc., when the number is not enough to meet the needs of the processes, it will cause the processes to compete for resources and cause deadlock.
Competition for temporary resources
The printer resources mentioned above are sequentially reusable resources and are called permanent resources. There is also a so-called temporary resource, which refers to a resource that is generated by one process, used by another process, and becomes useless after a short period of time. Therefore, it is also called a consumable resource, such as hardware interrupts, signals, messages, and buffers. messages, etc., it may also cause deadlock.
The above is the detailed content of Causes of system deadlock. For more information, please follow other related articles on the PHP Chinese website!