Multithreading < two > deadlock, Live Lock, starve, block understanding

Source: Internet
Author: User

Deadlock, deadlock, lock.

Thread A or B needs to cross the bridge (using the process), and C has not finished (the process is still occupied), so the three-party zombie;
can also be without C, a and B are not mutually comity zombie. Both A and B consider themselves the highest priority should use the process.

Live Lock Live Lock

Both threads A and b need to cross the bridge (both need to use the process), and all are comity (that is, the system has the same priority, it is not a high priority), so the stalemate.

Starve to death.

This is a single-plank bridge (one process), the bridge can only walk one person, B came when a on the bridge, b wait, and at this time than B age small C came, B let C current (a after the system to the process of the Division to C), C on the bridge, D again, B and let D in the current (c after the system to divide the process of a D) And so on, B has always been a wait state.

Blocking blocking

Deadlock:
1) Mutually exclusive condition: refers to the process of allocating resources to the exclusive use, that is, for a period of time a resource is occupied by only one process. If there are other processes requesting resources at this time, the requestor can wait until the resource-occupying process is freed.
2) Request and hold condition: means that the process has maintained at least one resource, but a new resource request has been made, and the resource has been occupied by another process, at which time the request process is blocked, but the other resources that you have obtained remain.
3) Non-deprivation conditions: Refers to the process has been obtained resources, before the end of use, can not be deprived, can only be released by themselves when the use is complete.
4) Loop wait condition: Refers to the deadlock, there must be a process-a circular chain of resources, that is, the process set {p0,p1,p2,,pn} P0 is waiting for a P1 to occupy the resources, P1 is waiting for the resources that P2 occupy, ..., Pn is waiting for the resources that have been occupied by P0.
Live Lock:
A live lock refers to a task or performer that is not blocked, because some conditions are not met, resulting in repeated attempts, failures, attempts, and failures. The difference between a live lock and a deadlock is that the entity that is in a live lock is constantly changing state, so-called "live", while the entity in the deadlock behaves as a wait; a live lock may be unlocked by itself, and a deadlock cannot. A live lock can be considered a special kind of starvation. The following example is considered a live lock in some articles. It's actually just a hunger. Because it does not reflect the characteristics of "living". This is a live lock, assuming the transaction T2 repeatedly trying to acquire the lock R.
Hunger:
Hunger is very similar to deadlocks and live locks. Refers to a situation in which a running process can continue to execute, but is ignored indefinitely by the scheduler and cannot be scheduled to execute. [1] hunger can be avoided by first serving resource allocation strategies.



Jokerone_
Links: https://www.jianshu.com/p/0494ab7c96f9
Source: Pinterest
The copyright of the book is owned by the author, and any form of reprint should be contacted by the author for authorization and attribution.

Multithreading < two > deadlock, Live Lock, starve, block understanding

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.