The concept of deadlock and the conditions of deadlock

零下一度
Release: 2017-06-23 16:16:22
Original
2585 people have browsed it

1. The concept of deadlock

If the synchronization of multiple threads is not designed properly, it will cause deadlock. Deadlock refers to a situation where multiple threads share certain resources and are waiting for each other to release the resources, causing the program to stagnate.

Deadlock will cause the program to stagnate, so we must pay attention to avoid deadlock when writing multi-threaded programs. In fact, the above problem is easy to solve, as long as the two threads access critical resources in the same order. Set the lock timeout. This method can also be used to avoid deadlock


2. Deadlock conditions

Mutual exclusion conditions: Resources cannot be shared, only Used by a process.

Request and retention conditions: A process that has obtained resources can apply for new resources again.

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

Loop waiting conditions: Several processes in the system form a loop, and each process in the loop is waiting for the resources occupied by adjacent processes.

The above is the detailed content of The concept of deadlock and the conditions of deadlock. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!