Open In App

Starvation and Aging in Operating Systems

Improve
Improve
Like Article
Like
Save
Share
Report

Starvation occurs when a process in the OS runs out of resources because other processes are using it. This is a problem with resource management while Operating systems employ aging as a scheduling approach to keep them from starving. It is one of the most common scheduling algorithms in batch systems. Each process is assigned a priority. The process with the highest priority is to be executed first and so on. Here we will be discussing a major problem related to priority scheduling and its solution.

What is Starvation?

Starvation or indefinite blocking is a phenomenon associated with the Priority scheduling algorithms, in which a process ready for the CPU (resources) can wait to run indefinitely because of low priority. In a heavily loaded computer system, a steady stream of higher-priority processes can prevent a low-priority process from ever getting the CPU. There have been rumors that in 1967 Priority Scheduling was used in IBM 7094 at MIT, and they found a low-priority process that had not been submitted till 1973.

Example:

Process

Burst Time

Priority

P1

4

10

P2

7

1

P3

10

2

Gantt Chart

P1

P3

P2

0

4

14

21

As we see in the above example 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 another process with high priority, this can lead to indefinitely waiting for the process for CPU which has priority, which leads to Starvation. Further, we have also discussed the solution to starvation. 

Reasons of Starvation

  • There are not enough resources available to everyone during starvation, and processes begin to lose priority.
  • If higher-priority processes continuously monopolize the processor, a lower-priority operation might have to wait indefinitely. As a result of the low-priority programs not communicating with anything, Starvation cannot result in a standstill.
  • A process may have to wait a lengthy period if a random selection of processes is employed due to non-selection.
  • Since starvation is a failsafe way to break a deadlock, the way it impacts the system as a whole is far more crucial.
  • Starvation may result if a process is never given the resources it needs to be executed due to poor resource allocation decisions.

How to Control Starvation?

  • Resource distribution can be handled by an impartial manager. In an effort to prevent starvation, this resource manager allocates resources equitably.
  • It is best to avoid choosing processes at random when allocating processors or resources because this promotes starvation.
  • The principles of Ageing, where a process’s priority increases the longer it waits to prevent starvation, should be included in the resource allocation priority system.

Differences Between Deadlock and Starvation in OS

  • 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 as shown in the figure below, on the other hand, Starvation occurs when a process waits for an indefinite period of time to get the resource it requires.
  • Another name for deadlock is Circular Waiting. Another name for starvation is Lived lock.
  • When deadlock occurs no process can make progress, while in starvation apart from the victim process other processes can progress or proceed.

Solution to Starvation: Aging

What is Aging?

Aging is a technique of gradually increasing the priority of processes that wait in the system for a long time. Operating systems employ ageing as a scheduling approach to keep them from starving. It is essentially giving long-waiting processes more importance one step at a time. It makes it more likely that they will obtain the tools they need to carry out. As a result, there is less chance of famine. In the event that the waiting process is not selected for execution, a higher priority is assigned to it. It guarantees that lengthy-waiting procedures are given an equal opportunity to complete. Ageing is combined with other scheduling techniques to avoid famine. Take round-robin or priority scheduling, for instance. It supports process scheduling by preserving a balance between immediate and long-term fairness. For example, if priority range from 127(low) to 0(high), we could increase the priority of a waiting process by 1 Every 15 minutes. Eventually, even a process with an initial priority of 127 would take no more than 32 hours for the priority 127 process to age to a priority-0 process.

Aging

Uses of Aging

  • In priority-based scheduling algorithms, the main purpose of ageing is to avoid resource hunger. Ageing guarantees that even lower-priority tasks eventually get an opportunity to execute by progressively raising the priority of waiting processes. This keeps resource distribution equitable and keeps no process from experiencing an endless resource shortage.
  • Ageing contributes to the equitable allocation of resources among processes. The operating system makes sure that every process, regardless of priority at first, receives its fair amount of resources and CPU time by gradually increasing the priority of waiting processes. Ageing Improves System Responsiveness. Ageing reduces the likelihood of some low-priority processes being held up in the wait line for an extended amount of time. They are provided opportunities to execute as their priority progressively rise, which improves system performance.
  • As people age, they become more balanced in terms of their processes’ levels of importance. It keeps lower-priority tasks from being entirely overlooked by preventing scenarios in which processes with drastically varying priorities coexist in the system.
  • Ageing is very helpful in optimising long-term performance. It avoids hunger and priority inversion, which can have a detrimental effect on the efficiency and throughput of the system as a whole.
  • Ageing Facilitates the System’s Ability to Adjust to Changing Workloads and Varying Process Requirements.

Limitation of Aging

  • Increased complexity: Aging requires additional overhead to periodically adjust the priorities of waiting processes, which can increase the overall complexity of the scheduling algorithm.
  • Overhead: Frequent priority adjustments may introduce additional overhead, which can reduce the overall efficiency of the scheduling algorithm.
  • Unpredictable behavior: Aging can lead to unpredictable behavior if the aging rate is not set appropriately. If the aging rate is too slow, it may take a long time for low-priority processes to receive the required resources. On the other hand, if the aging rate is too fast, it can cause high-priority processes to starve.
  • Unfairness: Aging can also be unfair to newly arrived processes as it prioritizes long waiting processes over new ones. This can lead to a situation where new processes are starved of resources while long waiting processes continue to receive them.

Frequently Asked Question on Starvation and Aging – FAQs

How is starvation avoided in OS?

Ageing is a method that raises the priority level of low-priority processes over a certain amount of time in order to prevent starvation in the operating system. As a result, both the high priority processes and the lowest priority processes will be able to continue existing and operating.

Can aging lead to priority inversion issues?

Yes aging leads to priority inversion problem

Can aging be used with real-time systems?

Real-time systems can benefit from the use of ageing, but its implementation must be carefully planned to save processing cost and guarantee that problems with priority inversion do not interfere with real-time requirements.



Last Updated : 22 Feb, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads