Causes of deadlock and four necessary conditions

Source: Internet
Author: User
The cause of the deadlock is as follows:
(1) Insufficient system resources.
(2) The order in which the process is promoted is inappropriate.
(3) improper resource allocation.
If the system resources are sufficient, all process resource requests can be satisfied, and the possibility of deadlock is very low. Otherwise
It will be deadlocked due to competition for limited resources. Second, the process may run in different order and speed, and may also lead to deadlocks.
Four Conditions for deadlock:
(1) mutex condition: A resource can only be used by one process at a time.
(2) request and retention conditions: when a process is blocked by requesting resources, it will not release the obtained resources.
(3) Non-deprivation condition: the resources obtained by the process cannot be forcibly deprived before they are used.
(4) Cyclic waiting condition: a cyclic waiting resource relationship is formed between several processes that are connected at the beginning and end.
The four conditions are: Conditions for deadlock , As long as the system has a deadlock, these conditions must be true, and as long as the above conditions
No deadlock will occur if it is not met.
Deadlock relief and prevention:
Understanding the cause of the deadlock, especially the four necessary conditions for deadlock, can avoid, prevent, and
Remove the deadlock. Therefore, in terms of system design and process scheduling, pay attention to how to prevent these four necessary conditions from being established and how to ensure
Rational Allocation of resources Algorithm To prevent processes from occupying system resources permanently. In addition, the process should be prevented from waiting.
. Therefore, reasonable planning should be made for resource allocation. The cause of the deadlock is as follows:
(1) Insufficient system resources.
(2) The order in which the process is promoted is inappropriate.
(3) improper resource allocation.
If the system resources are sufficient, all process resource requests can be satisfied, and the possibility of deadlock is very low. Otherwise
It will be deadlocked due to competition for limited resources. Second, the process may run in different order and speed, and may also lead to deadlocks.
Four Conditions for deadlock:
(1) mutex condition: A resource can only be used by one process at a time.
(2) request and retention conditions: when a process is blocked by requesting resources, it will not release the obtained resources.
(3) Non-deprivation condition: the resources obtained by the process cannot be forcibly deprived before they are used.
(4) Cyclic waiting condition: a cyclic waiting resource relationship is formed between several processes that are connected at the beginning and end.
The four conditions are: Conditions for deadlock , As long as the system has a deadlock, these conditions must be true, and as long as the above conditions
No deadlock will occur if it is not met.
Deadlock relief and prevention:
Understanding the cause of the deadlock, especially the four necessary conditions for deadlock, can avoid, prevent, and
Remove the deadlock. Therefore, in terms of system design and process scheduling, pay attention to how to prevent these four necessary conditions from being established and how to ensure
Set reasonable resource allocation algorithms to avoid permanent occupation of system resources by processes. In addition, the process should be prevented from waiting.
. Therefore, reasonable planning should be made for resource allocation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.