Difference Between Deadlock and Starvation

Deadlock vs Starvation

The main difference between deadlock and starvation is the cause and effect relationship between them; it is deadlock that causes starvation. Another interesting difference between deadlock and starvation is that deadlock is a problem while starvation can, sometimes, help to get out from a deadlock. In the computer world, when writing a computer program there will be more than one process/thread that will concurrently run one after the other in order to fulfill the required service to the program. Therefore, in order to have a fair system, the programmer should have to ensure that all the processes/threads will receive or get enough access to resources that they need. If not, there will be a deadlock, and it will lead to a starvation later. Generally, a fair system does not contain any deadlocks or starvations. Deadlocks and starvations will occur mainly when many threads are competing for limited resources.

What is Deadlock?

A deadlock is a condition that occurs when two threads or processes wait for each other to complete the task. They will only hang up but never stop or finish their task. In computer science, deadlocks can be seen everywhere. In a transaction database, when two processes each within its own transaction update the same two rows of information but in the opposite order, will cause a deadlock. In concurrent programming, a deadlock may occur when two competing actions will wait for each other to proceed forward. In telecommunications systems, a deadlock can happen due to loss or corruption of signals.

At present, deadlock is one of the main problems in multiprocessing systems and parallel computing. As a solution, a locking system called process synchronization is implemented for software as well as hardware.

 Difference Between Deadlock and Starvation

What is Starvation?

From the dictionary of medical science, starvation is a result of severe or total lack of nutrients that are needed for the maintenance of life. Similarly, in computer science, starvation is a problem that is encountered when multiple threads or processes wait for the same resource, which is called a deadlock.

In order to get out from a deadlock, one of the processes or threads should have to give up or roll back so that the other thread or process can use the resource. If this continuously happens and the same process or thread have to give up or roll back each time while letting other processes or threads to use the resource, then the selected process or thread, which rolled back will undergo a situation called starvation. Therefore, in order to get out from a deadlock, starvation is one of the solutions. Therefore, sometimes starvation is called a kind of a livelock. When there are many high priority processes or threads, a lower priority process or thread will always starve in a deadlock.

There can be many starvations such as starving on resources and starving on CPU. There are many common examples on starvation. They are Readers-writers problem and dining philosophers’ problem, which is more famous. There are five silent philosophers sitting at a round table with bowls of spaghetti. Forks are placed between each pair of adjacent philosophers. Each philosopher must alternately think and eat. However, a philosopher can only eat spaghetti when he has both left and right forks.

Deadlock vs Starvation

The “Dining Philosophers”

What is the difference between Deadlock and Starvation?

• Process:

• In deadlock, the two threads or processes will wait for each other and both do not proceed forward.

• In starvation, when two or more threads or processes wait for the same resource, one will roll back and let the others use the resource first and next the starving thread or process will try again . Therefore, all threads or processes will anyhow proceed forward.

• Rolling Back:

• In a deadlock, both high priority threads/processes, as well as low priority threads/processes, will wait for each other infinitely. It never ends.

• But, in a starvation, low priority ones will wait or roll back but high priority ones will proceed.

• Waiting or Lock:

• A deadlock is a circular waiting.

• A starvation is a kind of a livelock and sometimes helps to get out from a deadlock.

• Deadlock and Starvation:

• A deadlock causes starvation, but starvation does not cause a deadlock.

• Causes:

• A deadlock will occur due to mutual exclusion, hold and wait, no preemption or circular waiting.

• Starvation occurs due to scarcity of resources, uncontrolled management of resources, and process priorities.


Deadlock vs. Starvation

Deadlock and starvations are some of the problems that occur due to data races and race conditions that occur during programming as well as implementing hardware. In a deadlock, two threads will infinitely wait for each other without executing while, in a starvation, one thread will roll back and let the other thread to use the resources. A deadlock will cause starvation whereas starvation will help a thread to get out from a deadlock.


Images Courtesy:

  1. Computer by Steve Jurvetson from Menlo Park, USA (CC BY 2.0)
  2. The “Dining Philosophers” by Bdesham (CC BY-SA 3.0)
  • Jeson …

    thnx ..