The concept of deadlock and the condition of deadlock

Source: Internet
Author: User
First, the concept of deadlock

Synchronization of multiple threads can cause deadlocks if they are poorly designed. A deadlock is when multiple threads share certain resources while waiting for the other to release resources, causing the program to stagnate.

Deadlock can cause the program to stall, so we must be careful to avoid deadlocks when we write multi-threaded programs. In fact, the above problem is well solved, as long as two threads access critical resources in the same order. Set the lock timeout, which can also be used to avoid deadlocks


Ii. conditions of the deadlock

Mutex condition: A resource cannot be shared and can only be used by one process.

Request and hold condition: a process that has been given a resource can request a new resource again.

Non-deprivation: the resources already allocated cannot be forcibly deprived from the corresponding process.

Cyclic wait condition: Several processes in the system make up loops, and each process in the loop is waiting for the resources that the neighboring process is occupying.

Related Article

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.