Starvation:
Starvation is
phenomenon associated with the Priority scheduling algorithms. It is
sometimes called
indefinite blocking, in which a process
that is present in the ready state and has low priority, keeps on waiting for
the CPU allocation because some other process with higher priority comes with
due respect to time. Higher-priority
processes can prevent a low-priority process from getting the CPU.
Causes of Starvation:
- When starvation occurs, there are not enough resources to go around, and the priority of the processes starts becoming low.
- A lower priority process may wait forever if higher priority processes constantly monopolize the processor. Since the low priority programs are not interacting with anything, it becomes impossible for starvation to be a cause of a deadlock.
- If random selection of processes is used then a process may wait for a long time because of non-selection.
- Starvation is a fail-safe method in order to get out of a deadlock, making it much more important how it affects the system as a whole.
Example:
In the above example, process having
higher priority than other processes getting CPU earlier. We can think of a
scenario in which only one process is having very low-priority (for example
127) and we are giving other process with high-priority, this can lead
indefinitely waiting for the process for CPU which is having low-priority, this
leads to Starvation.
Aging: Solution to Starvation
Example: (Increasing Process)
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 priority 127
process to age to a priority-0 process.
Example: (Decreasing Process)
If a process P is
having a priority number as 127 at 0 minute. Then after every 15 minutes (time
quantum), decreasing the priority number of the process P by 1. So, after 15 m,
the priority of the process P will be 126. Again after 15 m, decreasing the
priority number of process P by 1. So, after 30 m, the priority of the process
P will become 125 and this process will continue. The process P will become a
high priority process when the priority number comes closer to 0 and the
process P will get the CPU for its execution after a very long period of time.
0 Comments