Table of Contents
Scheduling algorithms are essential in operating systems to manage process execution efficiently. They determine the order in which processes are allocated CPU time, impacting system performance and responsiveness. This article compares three common algorithms: First-Come, First-Served (FCFS), Shortest Job First (SJF), and Round Robin, with calculations to illustrate their differences.
First-Come, First-Served (FCFS)
FCFS schedules processes in the order they arrive. It is simple but can lead to long waiting times for shorter processes, known as the “convoy effect.”
Example: Processes with burst times 5, 3, and 8 arrive sequentially. The Gantt chart shows execution order and calculations for waiting and turnaround times.
Calculations:
- Process 1: Waiting Time = 0, Turnaround Time = 5
- Process 2: Waiting Time = 5, Turnaround Time = 8
- Process 3: Waiting Time = 8, Turnaround Time = 16
Shortest Job First (SJF)
SJF selects the process with the smallest burst time next. It minimizes average waiting time but requires knowledge of process durations beforehand.
Using the same processes, SJF schedules them as 3, 5, then 8 units, leading to different waiting times.
Calculations:
- Process 2: Waiting Time = 0, Turnaround Time = 3
- Process 1: Waiting Time = 3, Turnaround Time = 8
- Process 3: Waiting Time = 8, Turnaround Time = 16
Round Robin Scheduling
Round Robin assigns each process a fixed time slice or quantum. Processes are cycled through until completion, promoting fairness and responsiveness.
Assuming a quantum of 2 units, the processes are scheduled in cycles, and calculations are based on total execution time and waiting periods.
Example calculations for process completion times and waiting times are as follows:
- Process 1: Waiting Time = 4, Turnaround Time = 9
- Process 2: Waiting Time = 2, Turnaround Time = 5
- Process 3: Waiting Time = 8, Turnaround Time = 16