Live Lock (Livelock)
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 waiting;
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. If the transaction T1 block the data R, the transaction T2 also requests the Block R, so T2 waits. T3 also requested to block R, when T1 released the blockade on R, the system first approved the T3 request, T2 still waiting. Then T4 and asked to block R, when T3 released the blockade on R, the system approved the T4 request ... T2 may wait forever. A live lock should be a sequence of processes that wait for a certain impossible condition to be true in polling. The process is not blocked during a live lock, which can result in depletion of CPU resources. Example of a live lock
A live lock for a single entity for example, a thread takes a task from the queue to execute, and if the task fails, rejoin the task to the queue and continue execution. Assuming that the task always fails, or that a dependent condition is always unsatisfied, the thread is busy without any results. A typical example of a live lock life in synergy: Two of people meet in a narrow path while avoiding One direction and then avoiding it in another direction, so again and again. There are similar examples in communication, where multiple users share a channel (the simplest example is that everyone uses a walkie-talkie), and only one party can send messages at a time. The user who sends the signal will detect the conflict and, if there is a conflict, select the avoidance and then send. Assuming that the avoidance algorithm is unreasonable, it causes each send, conflict, avoidance and then send, or conflict. Example of a computer: Two threads have undergone some condition of the collision after the re-execution, then if there is still a collision after the attempt, there is a possibility of a live lock. Solutions for Live Locks
One solution to the cooperative live lock is to adjust the retry mechanism. such as introducing some randomness. For example, if a conflict is detected, pause a random amount of time to retry. This time greatly reduces the likelihood of collisions. A typical example is the CSMA/CD detection mechanism for Ethernet. In addition, in order to avoid possible deadlocks, it is an effective solution to add a certain number of retries appropriately. Although this can cause some complex logical processing in the business. For example, the contract retry mechanism avoids the conflict again. For example, the Automatic Collision prevention system (the hypothetical example) can be detected by the serial number of the collision risk, the small serial number of the aircraft to fly upward, the large number of aircraft flying down.
Http://baike.baidu.com/view/281236.htm
Live Lock (Livelock)