Operating Systems Lab Manual / OS Priority C Program

Program Name Write a C Program for CPU scheduling algorithm Priority.
Theory
In Priority CPU scheduling algorithm the process whose Priority is more 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 : 5
Enter Burst Time & Priority of Process 0 : 9 3
Enter Burst Time & Priority of Process 1 : 1 1
Enter Burst Time & Priority of Process 2 : 2 5
Enter Burst Time & Priority of Process 3 : 1 6
Enter Burst Time & Priority of Process 4 : 4 2
Output
Process      Priority 	             Burst Time 	   Waiting Time 	   Turn Around Time 
1 		 1 		         1 		            0 		        1 
4 		 2 		         4 		            1 		        5 
0 		 3 		         9 		            5 		        14 
2 		 5 		         2 		            14 		        16 
3 		 6 		         1 		            16 		        17 


Average Waiting Time: 7.200000 
Average Turnaround Time: 10.600000


Home     Back