Starvation in operating system
- CPU time
- Disk space
- Bandwidth of network
- I/O access to disk or network
What Causes Starvation in OS
Here are a few reasons why starvation in OS occurs
- In starvation, a process with low priority might wait forever if the process with higher priority uses a processor constantly.
- Because the low-priority processes are not interacting with resources the deadlock does not occur but there are chances of starvation as the low-priority processes are kept in a wait state.
- Hence starvation is precisely a fail-safe method, that is it prevents deadlock temporarily but it affects the system in general.
- The important cause of starvation might be that there are not enough resources to provide for every resource.
- If a process selection is random then there can be a possibility that a process might have to wait for a long duration.
- Starvation can also occur when a resource is never provided to a process for execution due to faulty allocation of resources.
Various Methods to Handle Starvation in OS
Here are the following ways in which the starvation situation in OS can be handled:
- The allocation of resources by CPU should be taken care of by a freelance manager to ensure that there is an even distribution of resources.
- Random choice of process method should be avoided due to which starvation occurs.
- The aging criteria of processes should be taken into consideration while resource allocation to avoid starvation.
- Scheduling algorithm with priority queue can also be used to handle starvation.
- If the random technique is to be used then use it with a priority queue to handle starvation.
- Multilevel feedback queue can also be used for avoiding starvation in the operating system.
Example of Starvation In Operating System
In the given example, the P2 process has the highest priority and process P1 has the lowest priority. In the diagram, it can be seen that there is n number of processes ready for their execution. So in the CPU, the process with the highest priority will come in which is P2 and the process P1 will keep waiting for its turn because all other processes are at a high priority concerning that P1. This situation in which the process is waiting is called starvation.
- Starvation is a problem of resource management where in the OS, the process does not has resources because it is being used by other processes.
- It is a problem when the low-priority process gets jammed for a long duration of time because of high-priority requests being executed.