Deadlock, Starvation & LiveLock


In operating system, there are some common types of "stucking" situations. Among these, Deadlock, Starvation, and Livelock are three well-known terms. Deadlock, Starvation, and Livelock are related concepts in computer science that deal with synchronization issues in concurrent systems. Understanding these concepts is important for designing and implementing correct and efficient concurrent systems.

  • Deadlock − A situation where two or more processes are waiting for each other to release a resource, creating a standstill.

    In other words, each process is holding a resource that the other process needs, and both are waiting for the other to release the resource. This creates a cycle of waiting, and neither process can continue executing. A deadlock is a serious problem in concurrent systems because it can cause processes to hang indefinitely, potentially leading to system failure.

    It's like two cars in opposite direction, in a narrow one-way lane trying to go ahead towards each other at the same time, both are waiting for the other to go back first, but neither do.

  • Starvation − A situation where a process is unable to acquire necessary resources it needs to continue processing, even though they are available, due to other processes are monopolizing them.

    This can lead to the process not being able to complete its execution, or taking much longer to complete than it should. Starvation can be caused by poor resource allocation algorithms or incorrect synchronization mechanisms.

    It's like a kid at a buffet who can never get to the food because bigger kids keep cutting in line.

  • Livelock − A situation where two or more processes continuously change their state in response to changes in the state of the other processes, but no progress is made.

    In other words, each process is reacting to the state of the other process, but neither process is able to make progress.

    It's like two cars approaching an intersection, both trying to give way to the other, but neither car is able to move forward.

    Livelocks are less common than deadlocks and starvation, but they can still cause problems in concurrent systems. To avoid livelocks, it is important to design processes and algorithms that can make progress despite changes in the state of other processes.

Similarities

Deadlock, Starvation, and Livelock are similar in the sense that they are all synchronization problems related to the coordination and management of resources in an operating system (OS) when managing concurrent processes. All three of these problems can lead to processes becoming blocked and unable to continue processing, leading to decreased performance and potential system failures. Additionally, all three can arise as a result of poor resource management and/or coordination between processes.

Here are some similarities between the three −

  • Occurrence in concurrent systems − All three problems occur in concurrent systems, where multiple processes share resources and compete for access to those resources.

  • Blocking of processes − In both deadlocks and livelocks, processes are blocked and unable to make progress, while in starvation, a process is blocked from accessing a resource for an extended period of time.

  • Impact on system efficiency − All three problems can impact the efficiency of a system by causing processes to wait or by consuming resources without making progress.

  • Need for synchronization mechanisms − All three problems can be avoided or minimized through the use of proper synchronization mechanisms, such as locks, semaphores, and monitors, which ensure fair and efficient access to shared resources.

All three of Deadlock, Starvation, and Livelock are types of synchronization problems that can occur in concurrent systems and affect system performance. They can be mitigated or prevented by implementing synchronization techniques.

Differentiate Deadlock v/s. Starvation v/s. Livelock

Here's a comparison table for Deadlock, Starvation, and Livelock −

Characteristics

Deadlock

Starvation

Livelock

Definition

Two or more processes waiting for each other to release resources, creating a standstill.

A process unable to acquire necessary resources due to other processes monopolizing them.

Two or more processes continuously changing their state in response to the state of the other processes, but no progress is made.

Causes

Poor resource management and coordination between processes, multiple processes accessing shared resources simultaneously.

Long-running processes monopolizing resources, lack of proper resource allocation, insufficient time slice.

Poor coordination between processes, lack of proper synchronization.

Result

Blocked processes, decreased performance, potential system failure.

Delayed or blocked processes, decreased performance, potential system failure.

No progress is made, continuous state changes, decreased performance.

Solution

Deadlocks can be resolved by using methods such as detection and recovery, prevention, and avoidance.

Starvation can be resolved by using priority scheduling, aging, and resource allocation.

Livelocks can be resolved by using methods such as breaking symmetry, randomness, and timeouts.

Conclusion

In summary, Deadlock is a situation where processes are blocked waiting for each other, Starvation is a situation where a process is waiting for a resource for an extended period of time, and Livelock is a situation where processes are continuously changing their state without making progress.

Updated on: 07-Apr-2023

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements