PRIORITY Scheduling Round Robin
PRIORITY Scheduling Round Robin
#include <stdio.h>
struct Process
{
int pid;
float burst;
float wait;
float turn;
float arr;
float comp;
int priority;
};
void main()
{
int n;
printf("Enter the number of processes:");
scanf("%d",&n);
struct Process pro[n];
for(int i=0;i<n;i++)
{
printf("Enter the arrival time of the process %d:",i+1);
scanf("%f",&pro[i].arr);
printf("Enter the burst time of process %d: ",i+1);
scanf("%f",&pro[i].burst);
printf("Enter the priority of process %d: ",i+1);
scanf("%d",&pro[i].priority);
pro[i].pid = i+1;
}
sort(pro,n);
calc_comp(pro,n);
calc_wait(pro,n);
calc_turn(pro,n);
for(int i=0;i<n;i++)
{
printf("%d\t\t%f\t%f\t%f\t%f\t%f\n",pro[i].pid,pro[i].arr,pro[i].wait,pro[i].burst,pro[i].comp,
pro[i].turn);
}
printf("Average waiting time = %f\nAverage turnaround time =
%f\n",avg_wait(pro,n),avg_turn(pro,n));
printf("\t");
for(int i=0;i<n;i++)
{
printf("P%d\t|\t",pro[i].pid);
}
printf("\n0\t");
int i;
for(i=0;i<n;i++)
{
printf("%f\t",pro[i].comp);
}
}
OUTPUT