Starvation in Operating System
Starvation is one of the major problems occurring when resource management is not done properly. This problem arises in the operating system when the resources are not being allocated for a long time to the processes which actually require them for execution. Processes that are of little importance or low preference are prohibited for an indefinite period of time to get the required resources.
In the situation of Starvation all the processes of higher precedence are always consuming all the available resources. A computer system that is fully loaded with various files, instructions, data, and processes contains a high chance that the processes of lower precedence are unable to reach the CPU (Central Processing Unit) of the system, hence leaving them without their execution. Starvation is called as a Lived lock.
Problem of Starvation
All the processes are lined up or queued to fulfil their optimum level of resources for their execution. And for the same purpose, processes are allotted with priority levels/numbers. Temporary jobs are given first scheduling or high priority. Zero (0) has the highest priority and the process with the largest number has the lowest priority.
Even if the process is available in the ready state for execution and has a lower level of priority, then it has to wait for a long period of time for execution. We all know that each and every problem comes along with its solution and the complicated Starvation also has a solution, which is termed as Aging.
Aging is basically a method or technique used to overcome the drawback of Starvation in any system. In Starvation each process is given some precedence or priority.
For example: if a system has 0- 200 processes and Z is a process with 197 priorities (nearly the least priority process), it means that Z has to wait for an indefinite period of time, as the resources are only allocated to the processes with higher precedence. There is a low possibility that Z will be executed.
Solution of Starvation
There are a few practical solutions mentioned below, which can be used to prevent the situation of Starvation and enhance the resource management:
- Aging: Aging is the required solution for Starvation. By using this aging method, we can moderately increase the priority of the processes that are waiting for a long time for their execution (increasing the priority level of the low process to slightly high and then to the processes of higher precedence).
Example: Let's suppose our system has a priority level from 0 to 520, and 520 belongs to the lowest priority.
Increase of process:
Suppose the priority of a system varies from 0 to 127, where 0 has the highest priority, and 127 has the least priority. In the aging method, we can increment the precedence of a holding process by one each minute; surprisingly, if a process with the lowest priority would take a maximum of 32 hours to become the process of highest priority (0) from the lowest priority because of Aging.
Decrease of the process:
If the priority of a system varies from 0 to 127, where 0 has the highest priority, and 127 has the least priority. Let's suppose our system has a process named Z which has the lowest priority at zero minutes, and if we decrement the precedence number of the lowest precedence Z by 1 in a time interval of 15 minutes. So, after passing 30 minutes, the precedence level of Z will be 125. After passing another thirty minutes, the precedence will rise to 123, and if this process continues, then the precedence of Z will rise near to the highest priority. It will get to the Central Processing Unit for the execution after a long-waited period of time.
- Independent Manager: Allocation of resources can be done under the supervision of an independent resource manager. The manager will justly and adequately allocate the resources to all the processes and also try to avoid the situation of Starvation.
- Random Selection: Random allocation of resources and unexpected ways of selecting processes (only priority-wise selection for execution) should be prohibited as they will surely result in Starvation.
Causes of Starvation
There are certain causes due to which the situation of Starvation arises in the Operating system
- Starvation also arises when a system lacks resources, leading to a decrease in the precedence of processes.
- There is a high chance that the lower precedence process has to wait for a non-ending span of time if processes with higher precedence are engrossing the resources, and since the lower processes are unable to interact with things required for execution, and it becomes really difficult for Starvation to source a deadlock.
- This starvation technique is also considered as a fail-safe technique to escape the deadlock, and as a whole, it affects the system.
- If the system is using an unexpected way for selecting the processes, then there must be a process waiting for a long time because of not getting a selection.
- The problem of Starvation arises when there are insufficient resources provided for the processes.
- Starvation can also be caused if any resources are never allocated to processes that actually need them for execution.