Difference between Deadlock and Starvation

Key Difference: Deadlock refers to the situation when processes are stuck in circular waiting for the resources. On the other hand, starvation occurs when a process waits for a resource indefinitely. Deadlock implies starvation but starvation does not imply deadlock.

In computer system memory printers, CPUs, tape drives, etc. can be considered as resources which need to be allocated to various processes due to their requirement. Generally, first a request is made by the process to use a resource, and after completion of its job, the process releases the resource to be used by some other process. A situation of deadlock arises when all the blocked processes of one set each occupies a resource and wait for the resource which is occupied by some other process in the set.

A simple example of it is a system with two tape drives, and two process each occupies one tape drive and waiting for the other as the requirement to proceed further.

It is important to mention that the situation of deadlock occus if these four conditions hold true all simultaneously –

  • Mutual exclusion – a resource can only be used by a process at a time
  • Hold and wait – a process which is occupying at least one resource needs to acquire an additional resource which is occupied by some other process, and therefore this process is waiting for that resource to get released
  • No preemption – resource is set free by only the process which has occupied it, after completion of its task.
  • Circular wait – all the processes in the sets are waiting for a resource which is held by other processes, which includes even the last process in the set.

On the other hand, starvation occurs when a particular process needs to wait indefinitely, as it never gets a chance to proceed further. In this situation, the process or transaction either waits indefinitely or gets in restarte mode again and again. This may happen in a deadlock situation when there is the possibility that the same process becomes a victim every time and gets rolled back. It is commonly found in propriety based scheduling systems.

It happens as a process of worse priority nevers gets the resource due to a constant flow of processes of better priority than it, and therefore the process might have to wait forever. The solution for dealing with starvation is to make sure that an independent manager should manage the allocations of resources, ensuring that every process gets the resource at some point of time. Random and uncontrolled selections or competition must be avoided to prevent starvation. Deadlock implies starvation but starvation do not implies deadlock.

Therefore, deadlock and starvation differs from each other. Deadlock occurs when none of the processes in the set is able to move ahead due to occupancy of the required resources by some other process. On the other hand, starvation occurs when a process waits for an indefinite period of time to get the resource it requires.

Comparison between Deadlock and Starvation:

 

Deadlock

Starvation

Definition

Deadlock occurs when none of the processes in the set is able to move ahead due to occupancy of the required resources by some other process

Starvation occurs when a process waits for an indefinite period of time to get the resource it requires.

Other name

Circular waiting

Lived lock

Arising conditions

These four conditions arising simultaneously – mutual exclusion, hold and wait, no-preemption and circular wit

Uncontrolled management of resources

Process priorities being strictly enforces
Use of random selection

Scarcity of resources

Avoidance/ prevention Techniques

  • Infinite resources
  • Waiting is not allowed
  • Sharing is not allowed
  • Preempt the resources
  • All Requests made at the starting
  • Independent manager for each resources
  • No strict enforcement of the priorities
  • Avoidance of random selection
  • Providing more resources

Progress

No process can make progress

Apart from the victim process other processes can progress or proceed

Ending

Requires external intervention

May or may not require external intervention

Image Courtesy: cs.nyu.edu, siber.cankaya.edu.tr

Most Searched in Beauty and Style Most Searched in Home and Garden
Most Searched in Games and Recreation Most Searched in Health
Of vs Off
Masjid vs Dargah
HP Slate 7 vs Nexus 7
Electronegativity vs Electron Affinity

Add new comment

Plain text

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.