- OS - Home
- OS - Needs
- OS - Overview
- OS - History
- OS - Components
- OS - Structure
- OS - Architecture
- OS - Services
- OS - Properties
- Process Management
- Processes in Operating System
- States of a Process
- Process Schedulers
- Process Control Block
- Operations on Processes
- Inter Process Communication (IPC)
- Context Switching
- Multi-threading
- Scheduling Algorithms
- Process Scheduling
- Types of Scheduling
- Scheduling Algorithms Overview
- FCFS Scheduling Algorithm
- SJF Scheduling Algorithm
- Round Robin Scheduling Algorithm
- HRRN Scheduling Algorithm
- Priority Scheduling Algorithm
- Multilevel Queue Scheduling
- Lottery Scheduling Algorithm
- Starvation and Aging
- Turn Around Time & Waiting Time
- Burst Time in SJF Scheduling
- Process Synchronization
- Process Synchronization
- Solutions For Process Synchronization
- Hardware-Based Solution
- Software-Based Solution
- Critical Section Problem
- Critical Section Synchronization
- Mutual Exclusion Synchronization
- Peterson's Algorithm
- Dekker's Algorithm
- Bakery Algorithm
- Semaphores
- Binary Semaphores
- Counting Semaphores
- Mutex
- Turn Variable
- Bounded Buffer Problem
- Reader Writer Locks
- Test and Set Lock
- Monitors
- Sleep and Wake
- Race Condition
- OS Deadlock
- Introduction to Deadlock
- Conditions for Deadlock
- Deadlock Handling
- Deadlock Prevention
- Deadlock Avoidance (Banker's Algorithm)
- Deadlock Detection and Recovery
- Deadlock Ignorance
- Memory Management
- Memory Management
- Contiguous Memory Allocation
- Non-Contiguous Memory Allocation
- First Fit Algorithm
- Next Fit Algorithm
- Best Fit Algorithm
- Worst Fit Algorithm
- Fragmentation
- Virtual Memory
- Segmentation
- Buddy System
- Slab Allocation
- Overlays
- Paging and Page Replacement
- Paging
- Demand Paging
- Page Table
- Page Replacement Algorithms
- Optimal Page Replacement Algorithm
- Belady's Anomaly
- Thrashing
- Storage and File Management
- File Systems
- File Attributes
- Structures of Directory
- Linked Index Allocation
- Indexed Allocation
- Disk Scheduling Algorithms
- FCFS Disk Scheduling
- SSTF Disk Scheduling
- SCAN Disk Scheduling
- LOOK Disk Scheduling
- I/O Systems
- I/O Hardware
- I/O Software
- OS Types
- OS - Types
- OS - Batch Processing
- OS - Multiprocessing
- OS - Hybrid
- OS - Monolithic
- OS - Zephyr
- OS - Nix
- OS - Linux
- OS - Blackberry
- OS - Garuda
- OS - Tails
- OS - Clustered
- OS - Haiku
- OS - AIX
- OS - Solus
- OS - Tizen
- OS - Bharat
- OS - Fire
- OS - Bliss
- OS - VxWorks
- OS - Embedded
- OS - Single User
- Miscellaneous Topics
- OS - Security
- OS Questions Answers
- OS - Questions Answers
- OS Useful Resources
- OS - Quick Guide
- OS - Useful Resources
- OS - Discussion
Operating System - Starvation and Aging
In operating systems, starvation and aging are two important concepts related to process scheduling and resource allocation. Starvation is a situation where a process is denied access to resources it needs for execution, and aging is a technique used to prevent starvation. In this chapter, we will discuss both concepts in detail.
Starvation in Operating System
Starvation is a situation in which a process is not able to gain access to the resources it needs for execution. This happens when CPU scheduling algorithm prefers other higher priority processes over the lower priority ones. As a result, some processes may need to wait indefinitely while other processes are being executed. Starvation is also known as indefinite blocking.
Example of Starvation
Consider a system that uses priority scheduling for CPU allocation. In this system, processes with higher priority are executed first. For example, assume that there are three processes P1, P2, and P3 with priorities 3, 2, and 1 respectively (higher number indicates higher priority). Following is the sequence of events −
Process Priority P1 3 (high priority) P2 2 P3 1 Process arrives in the order: P1, P2, P3, P2, P1, P2, P2, P1, P3, P1, P2, ... CPU allocation based on priority: P1 -> P2 -> P2 -> P1 -> P2 -> P2 -> P2 -> P1 -> P1 -> P2 -> ... Result: P3 never gets executed
In this example, P3 got starved because it has the lowest priority. As long as there are higher priority processes (P1 and P2) in the queue, P3 will never get a chance to execute.
Causes of Starvation
The main causes of starvation in operating systems are −
- Priority Scheduling − In priority scheduling algorithms, processes with higher priority are executed first. If there are always higher priority processes in the queue, lower priority processes may never get executed.
- Resource Allocation − If resources are allocated in a way that some processes are always denied access to the resources they need, those processes may starve.
- Deadlock − In some cases, deadlock can lead to starvation of multiple processes.
Aging in Operating System
Aging is a technique used to prevent starvation in operating systems. The idea behind aging is to gradually increase the priority of a process that are waiting in the queue for a long time. This way, even lower priority processes will eventually get a chance to execute.
Example of Aging
Continuing from the previous example, let's apply aging to the processes. Assume that for every time unit a process waits in the queue, its priority is increased by 1. The updated priorities of the processes after some time would be −
Process arrives in the order:
P1, P2, P3, P2, P1, P2, P2, P1, P3, P1, P2, ...
CPU allocation based on priority with aging:
Allocation Priority Now
-> Allocate P1 (priority 3) {P1: 3, P2: 2, P3: 1}
-> Allocate P2 (priority 2) {P1: 3, P2: 3, P3: 2}
-> Allocate P3 (priority 3) {P1: 3, P2: 3, P3: 3}
Result: No starvation, all processes get executed
In this example, after applying aging, P3's priority eventually increased to match that of P1 and P2. As a result, P3 got a chance to execute.
Conclusion
Starvation is a situation where a process is waiting for infinite time due to resource allocation policies. To prevent starvation, operating systems use aging technique, here the priority of waiting processes is gradually increased over time. Meaning the older processes will have high priority over time. This ensures that all processes eventually get a chance to execute.