Difference Between Deadlock and Starvation in OS



In operating systems, both deadlock and starvation are unwanted situations that take place when the processes that need a shared resource block each other's progress indefinitely. Both are unwanted situations; however, a deadlock is quite different than a starvation. In this article, we will discuss all the important differences between deadlock and starvation.

What is Deadlock?

A deadlock is a condition in operating systems in which no process proceeds for execution and waits for resources that have been acquired by some other processes. Thus, in the case of a deadlock condition, the process simply gets blocked.

Deadlock is also known as circular wait. It is because, in deadlock, the processes wait for resources in a circular fashion. When the four conditions namely mutual exclusion, hold and wait, no preemption, and circular wait occur simultaneously, then the condition of deadlock arises.

Deadlock is very common in distributed operating systems, multiprocessing operating systems, and parallel computing operating systems. Therefore, while developing a system, it is one of the important responsibilities of the programmer to design a deadlock free system.

What is Starvation?

Starvation occurs in a situation in which a process requests for a resource and that resource has been continuously used by some other processes. In starvation, a process that is ready to execute waits indefinitely for the CPU to allocate the resources. Thus, a situation arises in which other processes continuously block the requested resource. In starvation, the processes of high priority are executed and the low priority processes are blocked from accessing the requested resource. The problem of starvation can be resolved by aging.

Starvation can be caused by a deadlock, a livelock, or another process. A livelock is quite similar to a deadlock, with a slight difference. The processes involved in a deadlock are stuck indefinitely and they do not make any state change, whereas the processes in a livelock situation keep changing their resource state continuously, but still they block each other because the resource state change does not help the processes make any progress.

Difference between Deadlock and Starvation

The important differences between deadlock and starvation are highlighted in the following table −

Deadlock Starvation
A deadlock is a condition in operating systems in which no process proceeds for execution and wait for resources that have been acquired by some other processes. It is also known as circular wait. Starvation is a situation when a process keeps waiting (and starving) for a resource that is being held by other highpriority processes.
In a deadlock, all the involved processes keep waiting for each other to get completed. In this situation, the high priority processes are executed, and low priority processes are blocked.
In a deadlock, none of them can execute because they are waiting for the other process to complete. In starvation, the low priority process starves due to lack of resources.
The resources are blocked by the process. Resources are utilized by high priority process continuously.
The necessary conditions for deadlock are mutual exclusion, hold and wait, no pre-emption, and circular wait. In starvation, priorities are assigned to process.
Deadlock can be prevented by avoiding conditions such as mutual exclusion, hold and wait, no preemption and circular wait. Starvation can be prevented using the "Aging" technique.

Conclusion

In starvation, one or more processes starve due to the unavailability of a shared resource that is being continually used by other highpriority processes. A deadlock is the ultimate form of starvation when multiple processes starve and block each other's progress, because they are all waiting for a condition that cannot be satisfied. To conclude, both deadlock and starvation are undesired situations in an operating system where the involved processes block each other and make no progress.


Advertisements