Operating Systems Lab Manual / Shortest Job First (SJF)

Program Name Write a C Program for CPU scheduling algorithm Shortest Job First (SJF)
Theory
In Shortest Job First (SJF) the process whose job takes less time it will be served first by the processor.
The processor gets processes from the ready Queue. 

Waiting time (n) = waiting time (n-1) + Burst time (n-1)
Turnaround time (n)= waiting time(n)+Burst time(n)
Average waiting time = Total waiting Time / Number of process.
Average Turnaround time = Total Turnaround Time / Number of process.
Program
Input
Enter number of processes: 4
Enter Burst Time for Process 0: 3
Enter Burst Time for Process 1: 6
Enter Burst Time for Process 2: 7
Enter Burst Time for Process 3: 8
Output
	 Process 	 burst Time 	 Waiting Time 	 Turnaround Time

	 P0 		 3 		 0 		 3
	 P1 		 6 		 3 		 9
	 P2 		 7 		 9 		 16
	 P3 		 8 		 16 		 24
Average Waiting Time: 7.000000
Average Turnaround Time: 13.000000


Home     Back