Starvation and Aging in Operating Systems
Generally, Starvation occurs in Priority Scheduling or Shortest Job First Scheduling. In the Priority scheduling technique, we assign some priority to every process we have, and based on that priority, the CPU will be allocated, and the process will be executed. Here, the CPU will be allocated to the process that has the highest priority. Even if the burst time is low, the CPU will be allocated to the highest priority process.
Starvation is very bad for a process in an operating system, but we can overcome this starvation problem with the help of Aging.
What is Starvation?
Starvation or indefinite blocking is a phenomenon associated with the Priority scheduling algorithms. A process that is present in the ready state and has low priority keeps waiting for the CPU allocation because some other process with higher priority comes with due respect time. Higher-priority processes can prevent a low-priority process from getting the CPU.
For example, the above image process has higher priority than other processes getting CPU earlier. We can think of a scenario in which only one process has very low priority (for example, 127), and we are giving other processes high priority. This can lead to indefinitely waiting for the process for CPU, which is having low-priority, which leads to Starvation.
Causes of Starvation
Some of the common causes of Starvation in the operating system are as follows:
Solutions to Handle Starvation
Some solutions that can be implemented in a system to handle Starvation are as follows:
Differences between Starvation and Deadlock
Below are some differences between deadlock and Starvation in an operating system, such as:
What is Aging in OS?
In Operating systems, Aging is a scheduling technique used to avoid Starvation. Fixed priority scheduling is a scheduling discipline in which tasks queued for utilizing a system resource is assigned each priority. A task with a high priority is allowed to access a specific system resource before a task with a lower priority is allowed to do the same.
Aging is a technique of gradually increasing the priority (by time quantum) of processes that wait in the system for a long time. By doing so, as time passes, the lower priority process becomes a higher priority process.
A disadvantage of this approach is that tasks assigned with a lower priority may be starved when many high priority tasks are queued. Aging is used to gradually increase the priority of a task based on its waiting time in the ready queue.
In priority-based scheduling algorithms, a major problem is an indefinite block or Starvation. A process that is ready to run but waiting for the CPU can be considered blocked. A priority scheduling algorithm can leave some low-priority processes waiting indefinitely. A steady stream of higher-priority processes can prevent a low-priority process from ever getting the CPU.
Examples of Aging
Suppose a system with a priority range of 0-512. In this system, 0 means highest priority.
Uses of Aging
Aging is used to ensure that jobs with lower priority will eventually complete their execution. This technique can be used to reduce the Starvation of low priority tasks. There are many ways to implement Aging, but all have the same principle that the priority of a process should increase as it waits in the ready queue. The increase in priority may or may not be equal to the waiting time of the process.