Starvation and Deadlock are situations that occur when the processes that require a resource are delayed for a long time. However they are quite different concepts.
Details about starvation and deadlock are given as follows:
Starvation occurs if a process is indefinitely postponed. This may happen if the process requires a resource for execution that it is never alloted or if the process is never provided the processor for some reason.
Some of the common causes of starvation are as follows:
Some solutions that can be implemented in a system to handle starvation are as follows:
A deadlock occurs when two or more processes need some resource to complete their execution that is held by the other process.
In the above diagram, the process 1 has resource 1 and needs to acquire resource 2. Similarly process 2 has resource 2 and needs to acquire resource 1. Process 1 and process 2 are in deadlock as each of them needs the other’s resource to complete their execution but neither of them is willing to relinquish their resources.
A deadlock will only occur if the four Coffman conditions hold true. These conditions are not necessarily mutually exclusive. They are given as follows:
Mutual exclusion implies there should be a resource that can only be held by one process at a time. This means that the resources should be non-sharable.
A process can hold multiple resources and still request more resources from other processes which are holding them.
A resource cannot be preempted from a process by force. A process can only release a resource voluntarily.
A process is waiting for the resource held by the second process, which is waiting for the resource held by the third process and so on, till the last process is waiting for a resource held by the first process. This forms a circular chain.