Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
What are the types of process scheduling algorithms and which algorithms lead to starvation?
Process scheduler assigns different processes to the CPU based on particular scheduling algorithms. Each algorithm has different characteristics regarding fairness, efficiency, and the potential for starvation ? a condition where some processes may wait indefinitely.
Types of Process Scheduling Algorithms
The different types of process scheduling algorithms are as follows −
FCFS (First Come First Serve)
Jobs are executed on a first come first serve basis using a simple FIFO (First In First Out) queue. It is a non-preemptive algorithm where processes run to completion once started. While simple to implement, its performance is often poor due to the convoy effect where short processes wait behind long ones.
SJF (Shortest Job First)
Also known as Shortest Job Next, this algorithm selects the process with the smallest burst time. It can be implemented as both preemptive and non-preemptive. SJF is optimal for minimizing average waiting time but requires knowledge of future CPU burst times, making it impractical for interactive systems.
Round Robin
A preemptive scheduling algorithm where each process is given a fixed time slice called a quantum. After the quantum expires, the process is preempted and moved to the back of the ready queue. Context switching occurs between processes to save and restore their states, ensuring fair CPU distribution among all processes.
Priority Scheduling
Each process is assigned a priority value, and the CPU is allocated to the process with the highest priority. It can be implemented as both preemptive and non-preemptive. Higher priority processes are executed first, which can lead to lower priority processes experiencing starvation.
Shortest Remaining Time First (SRTF)
This is the preemptive version of SJF. The process with the shortest remaining burst time is selected for execution. When a new process arrives, if its burst time is shorter than the remaining time of the currently running process, the current process is preempted.
Multilevel Queue Scheduling
Multiple queues are maintained, each with its own scheduling algorithm. Processes are assigned to queues based on their characteristics (system processes, interactive processes, batch processes). Each queue has a priority, and higher priority queues are served first.
Preemptive vs Non-Preemptive
All algorithms can be implemented as preemptive or non-preemptive. In preemptive scheduling, the scheduler can interrupt a running process to allocate CPU to a higher priority process. In non-preemptive scheduling, once a process starts execution, it runs to completion without interruption.
Algorithms Leading to Starvation
| Algorithm | Starvation Risk | Explanation |
|---|---|---|
| FCFS | No | Every process eventually gets CPU time in arrival order |
| Round Robin | No | Each process gets regular CPU time through time slicing |
| SJF | Yes | Long processes may wait indefinitely if short jobs keep arriving |
| Priority Scheduling | Yes | Low priority processes may never execute if high priority jobs keep coming |
| SRTF | Yes | Processes with long burst times may be continuously preempted |
Starvation Prevention
Starvation can be prevented using techniques like aging, where the priority of waiting processes is gradually increased over time, ensuring that even low-priority processes eventually get CPU access.
Conclusion
Different scheduling algorithms have varying trade-offs between efficiency and fairness. While SJF and Priority Scheduling can lead to starvation of certain processes, algorithms like FCFS and Round Robin ensure all processes eventually receive CPU time. The choice depends on system requirements and workload characteristics.
