Livelock: What is, Example, Difference with Deadlock
โก Smart Summary
Livelock is a concurrency situation where processes keep changing their states in response to one another yet make no real progress, staying active and consuming CPU cycles without ever completing their tasks or becoming blocked.

What is Livelock?
A Livelock is a situation where a request for an exclusive lock is denied repeatedly, as many overlapping shared locks keep interfering with each other. The processes keep changing their status, which prevents them from completing the task.
Examples of Livelock
Example 1:
The easiest example of Livelock is two people who meet face-to-face in a corridor, and both of them move aside to let the other pass. They keep moving from side to side without making any progress because they move the same way at the same time. Here, they never cross each other.
Example 2:
In the image above, each of the two processes needs two resources, and they use primitive polling to try to acquire the locks they need. If an attempt fails, the method tries again.
- Process A holds resource Y
- Process B holds resource X
- Process A requires resource X
- Process B requires resource Y
Assume process A runs first and acquires resource X, and then process B runs and acquires resource Y. No matter which process runs first, neither of them makes further progress.
However, neither of the two processes is blocked. They use up CPU resources repeatedly without making any progress, yet they never stop for a processing block.
Therefore, this situation is not a deadlock, because not a single process is blocked; instead, we face a situation equivalent to deadlock, which is called LIVELOCK.
What Leads to Livelock?
Livelock is tied to the number of processes a system permits, which is defined by the total number of entries in the process table. These process-table slots are therefore treated as finite resources. When processes repeatedly retry for these limited resources while continually yielding to one another, none of them makes progress, and the system enters a livelock.
What is Deadlock?
A deadlock is a situation that occurs in an OS when a process enters a waiting state because another waiting process is holding the demanded resource. Deadlock is a common problem in multiprocessing, where several processes share a specific type of mutually exclusive resource known as a soft lock or software.
Example of Deadlock
- A real-world example would be traffic that is going in only one direction.
- Here, a bridge is considered a resource.
- When a deadlock happens, it can be resolved easily if one car backs up (preempt resources and roll back).
- Several cars may have to be backed up if a deadlock situation occurs.
- Therefore, starvation is possible.
Example of Deadlock
What is Starvation?
Starvation is a situation where low-priority processes are blocked while high-priority processes proceed. In any system, requests for high- and low-priority resources keep happening dynamically. Therefore, some policy is required to decide who gets served and when.
With some algorithms, certain processes may not get the desired service even though they are not deadlocked. Starvation occurs when some threads make shared resources unavailable for a long period of time.
Example of Starvation
For example, an object offers a synchronized method that is likely to take a long time to return. If one thread uses this method frequently, other threads that also need frequent synchronized access to the same object are often blocked.
Difference Between Deadlock, Starvation, and Livelock
- A deadlock is a situation that occurs in an OS when a process enters a waiting state because the demanded resource is held by another waiting process.
- A livelock, on the other hand, is almost similar to a deadlock, except that the states of the processes involved in a livelock always keep changing in response to one another, with none progressing.
- So, livelock is a unique case of resource starvation.


