Question operating systemoperating system For SRTF and SJF algorithms study and develop them using C programming language $ SS in a Linux environment, the data for SRTF and SJF are: Process Arrival Time Burst Time P1 14 12 17

0P1YPV The Asker · Computer Science
operating system


operating system
Transcribed Image Text: For SRTF and SJF algorithms study and develop them using C programming language $ SS in a Linux environment, the data for SRTF and SJF are: Process Arrival Time Burst Time P1 14 12 17
More
Transcribed Image Text: For SRTF and SJF algorithms study and develop them using C programming language $ SS in a Linux environment, the data for SRTF and SJF are: Process Arrival Time Burst Time P1 14 12 17
Community Answer
PDZO2X

SJF algorithm C code #include<stdio.h> struct SJF {         int P_NO,AT,BT,CT,WT,BT1,TAT,index; }; int main() {     // ask user to enter no.of processes         printf("Enter no.of processes: ");                  // declare an variable to store no.of processes, array to completion value of each process         int np,cvalue[100],s=0,complete[100];                  // declare variable to store average turn-around time, average waiting time, throughput etc         float Avg_TAT=0,Avg_WT=0,ctmax,l,Throughtput,atmin;                  // read no.of process from user         scanf("%d",&np);                  // declare a array of structures with size of no.of processes         struct SJF p_details[np];                  // ask user to enter Process id, arrival time and burst time         printf("Enter PID and AT and BT for each process:\n");         int i;                  // read pid, arrival time, burst time for n processes         for(i=0;i<np;i++)         {                 scanf("%d%d%d",&p_details[i].P_NO,&p_details[i].AT,&p_details[i].BT);         }                  int c=0,v=0,f=0,z1=0;         int status=0,z=0;                  // iterate for loop         for(i=0;i<np;)         {                 int j=0,t=0,f=0;                 while(j<np)                 {                         char ch=p_details[j].BT;                         if(ch!='.' && p_details[j].AT<=c)                         {                                 p_details[t].index=j;                                 t++;                                 f++;                         }                         j++;                 }                 if(f>=1)                 {                         int k=0,in=p_details[0].index;                         int min=p_details[in].BT,m=in;                         for(k=1;k<t;k++)                         {                                 in=p_details[k].index;                                 if(min>p_details[in].BT)                                 {                                         min=p_details[in].BT;                                         m=in;                                 }                         }                           if(i==0)                         {                                 atmin=p_details[m].AT;                         }                         if(status==1)                         {                                 cvalue[z]=c;                                 z++;                                 status=0;                                 s=0;                         }                             p_details[m].CT=p_details[m].BT+c;                         c=p_details[m].CT;                         p_details[m].BT1=p_details[m].BT;                         p_details[m].BT='.';                         cvalue[z]=c;                         i++;                         complete[z1]=p_details[m].P_NO;                         z1++;                         ctmax=p_details[m].CT;                         z++;                 }                 else                 {                              c++;                         if(s==0)                         {                                 complete[z1]=-1;                                 z1++;                         }                         status=1;                         s++;                 }                          }                  // print gantt chart         printf("\n");         printf("\t\tGantt chart     \n");         printf(" ");         for(i=0;i<(z1*8)-1;i++)         {                 printf("-");         }         printf("\n");         printf("|");         for(i=0;i<z1;i++)         {                 if(complete[i]==-1)                 {                         printf(" #     |");                 }                 else                 {                         printf(" p%d ",complete[i]);                         int number=complete[i],h=0;                         for(;number>0;)                         {                                 h++;                                 number=number/10;                         }                         h=3-h;                         for(h;h>0;h--)                         {                                 printf(" ");                         }                         printf(" |");                 }                                  }         printf("\n");         printf(" ");         for(i=0;i<(z1*8)-1;i++)         {                 printf("-");         }         printf("\n");         printf("0");         for(i=0;i<z;i++)         {                 int number=cvalue[i],h=0;                 for(;number>0;)                 {                         h++;                         number=number/10;                 }                 h=3-h;                 printf("     ");                 for(h;h>0;h--)                 {                         printf(" ");                 }                 printf("%d",cvalue[i]);                                                   }         printf("\n\n");         printf("\t\tTable\n");         printf(" ");         for(i=0;i<56;i++)         {                 printf("-");         }         printf("\n");         printf("|\tPID\tAT\tBT\tCT\tTAT\tWT\t |\n");         printf(" ");         for(i=0;i<56;i++)         {                 printf("-");         }         printf("\n");                  // calculate turn-around time, waiting time of each process         for(i=0;i<np;i++)         {                 p_details[i].TAT=p_details[i].CT-p_details[i].AT;                 p_details[i].WT=p_details[i].TAT-p_details[i].BT1;                 Avg_TAT=Avg_TAT+p_details[i].TAT;                 Avg_WT=Avg_WT+p_details[i].WT;         }                  // print the table         for(i=0;i<np;i++)         {                 printf("|\t%d\t%d\t%d\t%d\t%d\t%d\t |\n",p_details[i].P_NO,p_details[i].AT,p_details[i].BT1,p_details[i].CT,p_details[i].TAT,p_details[i].WT);                 printf(" ");                 int j;                 for(j=0;j<56;j++)                 {                         printf("-");                 }                 printf("\n");         }         printf("\n");                  //calculate average waiting time, average turn-around time         Avg_TAT=Avg_TAT/np;         Avg_WT=Avg_WT/np;                  // calculate l value         l=(ctmax-atmin);                  // calculate throughput         Throughtput=np/l;                  // print average waiting time, average waiting time, l value, throughtput         printf("Avg_TAT=%.2f\nAvg_WT=%.2f\nl=%d\nThroughtput=%.2f\n",Avg_TAT,Avg_WT,(int)l,Throughtput);                               } Sample Input/Output rgukt-rkv@rguktrkv-TravelMate-P243-M: /Downloads/os labs programs/scheduling algorithms SRTF algorithm C code #include<stdio.h> #include<string.h> struct SRTF {         int P_NO,AT,BT,CT,WT,BT1,TAT,index; }; int main() {     // ask user to enter no.of processe         printf("Enter no.of processes: ");                  // declare an variable to store no.of processes, array to completion value of each process         int np,cvalue[100],s=0,complete[100],z1=0;                  // declare variable to store average turn-around time, average waiting time, throughput etc         float Avg_TAT=0,Avg_WT=0,ctmax,atmin,l,Throughput;                  // read no.of process from user         scanf("%d",&np);                  // declare a array of structures with size of no.of processes         struct SRTF p_details[np];                  // ask user to enter Process id, arrival time and burst time         printf("Enter PID and AT and BT for each process:\n");         int i;                   // read pid, arrival time, burst time for n processes         for(i=0;i<np;i++)         {                 scanf("%d%d%d",&p_details[i].P_NO,&p_details[i].AT,&p_details[i].BT);                 p_details[i].BT1=p_details[i].BT;         }         int c=0,v=0,f=0,y=0;         int status=0,z=0;                  // iterate for loop         for(i=0;i<np;)         {                 int j=0,t=0;                 f=0;                 while(j<np)                 {                         char ch=p_details[j].BT;                         if(ch!='.' && p_details[j].AT<=c)                         {                                 p_details[t].index=j;                                 t++;                                 f++;                         }       ... See the full answer

KVACDC

SJF algorithm C code #include<stdio.h> struct SJF {         int P_NO,AT,BT,CT,WT,BT1,TAT,index; }; int main() {     // ask user to enter no.of processes         printf("Enter no.of processes: ");                  // declare an variable to store no.of processes, array to completion value of each process         int np,cvalue[100],s=0,complete[100];                  // declare variable to store average turn-around time, average waiting time, throughput etc         float Avg_TAT=0,Avg_WT=0,ctmax,l,Throughtput,atmin;                  // read no.of process from user         scanf("%d",&np);                  // declare a array of structures with size of no.of processes         struct SJF p_details[np];                  // ask user to enter Process id, arrival time and burst time         printf("Enter PID and AT and BT for each process:\n");         int i;                  // read pid, arrival time, burst time for n processes         for(i=0;i<np;i++)         {                 scanf("%d%d%d",&p_details[i].P_NO,&p_details[i].AT,&p_details[i].BT);         }                  int c=0,v=0,f=0,z1=0;         int status=0,z=0;                  // iterate for loop         for(i=0;i<np;)         {                 int j=0,t=0,f=0;                 while(j<np)                 {                         char ch=p_details[j].BT;                         if(ch!='.' && p_details[j].AT<=c)                         {                                 p_details[t].index=j;                                 t++;                                 f++;                         }                         j++;                 }                 if(f>=1)                 {                         int k=0,in=p_details[0].index;                         int min=p_details[in].BT,m=in;                         for(k=1;k<t;k++)                         {                                 in=p_details[k].index;                                 if(min>p_details[in].BT)                                 {                                         min=p_details[in].BT;                                         m=in;                                 }                         }                           if(i==0)                         {                                 atmin=p_details[m].AT;                         }                         if(status==1)                         {                                 cvalue[z]=c;                                 z++;                                 status=0;                                 s=0;                         }                             p_details[m].CT=p_details[m].BT+c;                         c=p_details[m].CT;                         p_details[m].BT1=p_details[m].BT;                         p_details[m].BT='.';                         cvalue[z]=c;                         i++;                         complete[z1]=p_details[m].P_NO;                         z1++;                         ctmax=p_details[m].CT;                         z++;                 }                 else                 {                              c++;                         if(s==0)                         {                                 complete[z1]=-1;                                 z1++;                         }                         status=1;                         s++;                 }                          }                  // print gantt chart         printf("\n");         printf("\t\tGantt chart     \n");         printf(" ");         for(i=0;i<(z1*8)-1;i++)         {                 printf("-");         }         printf("\n");         printf("|");         for(i=0;i<z1;i++)         {                 if(complete[i]==-1)                 {                         printf(" #     |");                 }                 else                 {                         printf(" p%d ",complete[i]);                         int number=complete[i],h=0;                         for(;number>0;)                         {                                 h++;                                 number=number/10;                         }                         h=3-h;                         for(h;h>0;h--)                         {                                 printf(" ");                         }                         printf(" |");                 }                                  }         printf("\n");         printf(" ");         for(i=0;i<(z1*8)-1;i++)         {                 printf("-");         }         printf("\n");         printf("0");         for(i=0;i<z;i++)         {                 int number=cvalue[i],h=0;                 for(;number>0;)                 {                         h++;                         number=number/10;                 }                 h=3-h;                 printf("     ");                 for(h;h>0;h--)                 {                         printf(" ");                 }                 printf("%d",cvalue[i]);                                                   }         printf("\n\n");         printf("\t\tTable\n");         printf(" ");         for(i=0;i<56;i++)         {                 printf("-");         }         printf("\n");         printf("|\tPID\tAT\tBT\tCT\tTAT\tWT\t |\n");         printf(" ");         for(i=0;i<56;i++)         {                 printf("-");         }         printf("\n");                  // calculate turn-around time, waiting time of each process         for(i=0;i<np;i++)         {                 p_details[i].TAT=p_details[i].CT-p_details[i].AT;                 p_details[i].WT=p_details[i].TAT-p_details[i].BT1;                 Avg_TAT=Avg_TAT+p_details[i].TAT;                 Avg_WT=Avg_WT+p_details[i].WT;         }                  // print the table         for(i=0;i<np;i++)         {                 printf("|\t%d\t%d\t%d\t%d\t%d\t%d\t |\n",p_details[i].P_NO,p_details[i].AT,p_details[i].BT1,p_details[i].CT,p_details[i].TAT,p_details[i].WT);                 printf(" ");                 int j;                 for(j=0;j<56;j++)                 {                         printf("-");                 }                 printf("\n");         }         printf("\n");                  //calculate average waiting time, average turn-around time         Avg_TAT=Avg_TAT/np;         Avg_WT=Avg_WT/np;                  // calculate l value         l=(ctmax-atmin);                  // calculate throughput         Throughtput=np/l;                  // print average waiting time, average waiting time, l value, throughtput         printf("Avg_TAT=%.2f\nAvg_WT=%.2f\nl=%d\nThroughtput=%.2f\n",Avg_TAT,Avg_WT,(int)l,Throughtput);                               } Sample Input/Output rgukt-rkv@rguktrkv-TravelMate-P243-M: /Downloads/os labs programs/scheduling algorithms SRTF algorithm C code #include<stdio.h> #include<string.h> struct SRTF {         int P_NO,AT,BT,CT,WT,BT1,TAT,index; }; int main() {     // ask user to enter no.of processe         printf("Enter no.of processes: ");                  // declare an variable to store no.of processes, array to completion value of each process         int np,cvalue[100],s=0,complete[100],z1=0;                  // declare variable to store average turn-around time, average waiting time, throughput etc         float Avg_TAT=0,Avg_WT=0,ctmax,atmin,l,Throughput;                  // read no.of process from user         scanf("%d",&np);                  // declare a array of structures with size of no.of processes         struct SRTF p_details[np];                  // ask user to enter Process id, arrival time and burst time         printf("Enter PID and AT and BT for each process:\n");         int i;                   // read pid, arrival time, burst time for n processes         for(i=0;i<np;i++)         {                 scanf("%d%d%d",&p_details[i].P_NO,&p_details[i].AT,&p_details[i].BT);                 p_details[i].BT1=p_details[i].BT;         }         int c=0,v=0,f=0,y=0;         int status=0,z=0;                  // iterate for loop         for(i=0;i<np;)         {                 int j=0,t=0;                 f=0;                 while(j<np)                 {                         char ch=p_details[j].BT;                         if(ch!='.' && p_details[j].AT<=c)                         {                                 p_details[t].index=j;                                 t++;                                 f++;                         }       ... See the full answer

G10LFI

SJF algorithm C code #include<stdio.h> struct SJF {         int P_NO,AT,BT,CT,WT,BT1,TAT,index; }; int main() {     // ask user to enter no.of processes         printf("Enter no.of processes: ");                  // declare an variable to store no.of processes, array to completion value of each process         int np,cvalue[100],s=0,complete[100];                  // declare variable to store average turn-around time, average waiting time, throughput etc         float Avg_TAT=0,Avg_WT=0,ctmax,l,Throughtput,atmin;                  // read no.of process from user         scanf("%d",&np);                  // declare a array of structures with size of no.of processes         struct SJF p_details[np];                  // ask user to enter Process id, arrival time and burst time         printf("Enter PID and AT and BT for each process:\n");         int i;                  // read pid, arrival time, burst time for n processes         for(i=0;i<np;i++)         {                 scanf("%d%d%d",&p_details[i].P_NO,&p_details[i].AT,&p_details[i].BT);         }                  int c=0,v=0,f=0,z1=0;         int status=0,z=0;                  // iterate for loop         for(i=0;i<np;)         {                 int j=0,t=0,f=0;                 while(j<np)                 {                         char ch=p_details[j].BT;                         if(ch!='.' && p_details[j].AT<=c)                         {                                 p_details[t].index=j;                                 t++;                                 f++;                         }                         j++;                 }                 if(f>=1)                 {                         int k=0,in=p_details[0].index;                         int min=p_details[in].BT,m=in;                         for(k=1;k<t;k++)                         {                                 in=p_details[k].index;                                 if(min>p_details[in].BT)                                 {                                         min=p_details[in].BT;                                         m=in;                                 }                         }                           if(i==0)                         {                                 atmin=p_details[m].AT;                         }                         if(status==1)                         {                                 cvalue[z]=c;                                 z++;                                 status=0;                                 s=0;                         }                             p_details[m].CT=p_details[m].BT+c;                         c=p_details[m].CT;                         p_details[m].BT1=p_details[m].BT;                         p_details[m].BT='.';                         cvalue[z]=c;                         i++;                         complete[z1]=p_details[m].P_NO;                         z1++;                         ctmax=p_details[m].CT;                         z++;                 }                 else                 {                              c++;                         if(s==0)                         {                                 complete[z1]=-1;                                 z1++;                         }                         status=1;                         s++;                 }                          }                  // print gantt chart         printf("\n");         printf("\t\tGantt chart     \n");         printf(" ");         for(i=0;i<(z1*8)-1;i++)         {                 printf("-");         }         printf("\n");         printf("|");         for(i=0;i<z1;i++)         {                 if(complete[i]==-1)                 {                         printf(" #     |");                 }                 else                 {                         printf(" p%d ",complete[i]);                         int number=complete[i],h=0;                         for(;number>0;)                         {                                 h++;                                 number=number/10;                         }                         h=3-h;                         for(h;h>0;h--)                         {                                 printf(" ");                         }                         printf(" |");                 }                                  }         printf("\n");         printf(" ");         for(i=0;i<(z1*8)-1;i++)         {                 printf("-");         }         printf("\n");         printf("0");         for(i=0;i<z;i++)         {                 int number=cvalue[i],h=0;                 for(;number>0;)                 {                         h++;                         number=number/10;                 }                 h=3-h;                 printf("     ");                 for(h;h>0;h--)                 {                         printf(" ");                 }                 printf("%d",cvalue[i]);                                                   }         printf("\n\n");         printf("\t\tTable\n");         printf(" ");         for(i=0;i<56;i++)         {                 printf("-");         }         printf("\n");         printf("|\tPID\tAT\tBT\tCT\tTAT\tWT\t |\n");         printf(" ");         for(i=0;i<56;i++)         {                 printf("-");         }         printf("\n");                  // calculate turn-around time, waiting time of each process         for(i=0;i<np;i++)         {                 p_details[i].TAT=p_details[i].CT-p_details[i].AT;                 p_details[i].WT=p_details[i].TAT-p_details[i].BT1;                 Avg_TAT=Avg_TAT+p_details[i].TAT;                 Avg_WT=Avg_WT+p_details[i].WT;         }                  // print the table         for(i=0;i<np;i++)         {                 printf("|\t%d\t%d\t%d\t%d\t%d\t%d\t |\n",p_details[i].P_NO,p_details[i].AT,p_details[i].BT1,p_details[i].CT,p_details[i].TAT,p_details[i].WT);                 printf(" ");                 int j;                 for(j=0;j<56;j++)                 {                         printf("-");                 }                 printf("\n");         }         printf("\n");                  //calculate average waiting time, average turn-around time         Avg_TAT=Avg_TAT/np;         Avg_WT=Avg_WT/np;                  // calculate l value         l=(ctmax-atmin);                  // calculate throughput         Throughtput=np/l;                  // print average waiting time, average waiting time, l value, throughtput         printf("Avg_TAT=%.2f\nAvg_WT=%.2f\nl=%d\nThroughtput=%.2f\n",Avg_TAT,Avg_WT,(int)l,Throughtput);                               } Sample Input/Output rgukt-rkv@rguktrkv-TravelMate-P243-M: /Downloads/os labs programs/scheduling algorithms SRTF algorithm C code #include<stdio.h> #include<string.h> struct SRTF {         int P_NO,AT,BT,CT,WT,BT1,TAT,index; }; int main() {     // ask user to enter no.of processe         printf("Enter no.of processes: ");                  // declare an variable to store no.of processes, array to completion value of each process         int np,cvalue[100],s=0,complete[100],z1=0;                  // declare variable to store average turn-around time, average waiting time, throughput etc         float Avg_TAT=0,Avg_WT=0,ctmax,atmin,l,Throughput;                  // read no.of process from user         scanf("%d",&np);                  // declare a array of structures with size of no.of processes         struct SRTF p_details[np];                  // ask user to enter Process id, arrival time and burst time         printf("Enter PID and AT and BT for each process:\n");         int i;                   // read pid, arrival time, burst time for n processes         for(i=0;i<np;i++)         {                 scanf("%d%d%d",&p_details[i].P_NO,&p_details[i].AT,&p_details[i].BT);                 p_details[i].BT1=p_details[i].BT;         }         int c=0,v=0,f=0,y=0;         int status=0,z=0;                  // iterate for loop         for(i=0;i<np;)         {                 int j=0,t=0;                 f=0;                 while(j<np)                 {                         char ch=p_details[j].BT;                         if(ch!='.' && p_details[j].AT<=c)                         {                                 p_details[t].index=j;                                 t++;                                 f++;                         }       ... See the full answer

VLZIQL

SJF algorithm C code #include<stdio.h> struct SJF {         int P_NO,AT,BT,CT,WT,BT1,TAT,index; }; int main() {     // ask user to enter no.of processes         printf("Enter no.of processes: ");                  // declare an variable to store no.of processes, array to completion value of each process         int np,cvalue[100],s=0,complete[100];                  // declare variable to store average turn-around time, average waiting time, throughput etc         float Avg_TAT=0,Avg_WT=0,ctmax,l,Throughtput,atmin;                  // read no.of process from user         scanf("%d",&np);                  // declare a array of structures with size of no.of processes         struct SJF p_details[np];                  // ask user to enter Process id, arrival time and burst time         printf("Enter PID and AT and BT for each process:\n");         int i;                  // read pid, arrival time, burst time for n processes         for(i=0;i<np;i++)         {                 scanf("%d%d%d",&p_details[i].P_NO,&p_details[i].AT,&p_details[i].BT);         }                  int c=0,v=0,f=0,z1=0;         int status=0,z=0;                  // iterate for loop         for(i=0;i<np;)         {                 int j=0,t=0,f=0;                 while(j<np)                 {                         char ch=p_details[j].BT;                         if(ch!='.' && p_details[j].AT<=c)                         {                                 p_details[t].index=j;                                 t++;                                 f++;                         }                         j++;                 }                 if(f>=1)                 {                         int k=0,in=p_details[0].index;                         int min=p_details[in].BT,m=in;                         for(k=1;k<t;k++)                         {                                 in=p_details[k].index;                                 if(min>p_details[in].BT)                                 {                                         min=p_details[in].BT;                                         m=in;                                 }                         }                           if(i==0)                         {                                 atmin=p_details[m].AT;                         }                         if(status==1)                         {                                 cvalue[z]=c;                                 z++;                                 status=0;                                 s=0;                         }                             p_details[m].CT=p_details[m].BT+c;                         c=p_details[m].CT;                         p_details[m].BT1=p_details[m].BT;                         p_details[m].BT='.';                         cvalue[z]=c;                         i++;                         complete[z1]=p_details[m].P_NO;                         z1++;                         ctmax=p_details[m].CT;                         z++;                 }                 else                 {                              c++;                         if(s==0)                         {                                 complete[z1]=-1;                                 z1++;                         }                         status=1;                         s++;                 }                          }                  // print gantt chart         printf("\n");         printf("\t\tGantt chart     \n");         printf(" ");         for(i=0;i<(z1*8)-1;i++)         {                 printf("-");         }         printf("\n");         printf("|");         for(i=0;i<z1;i++)         {                 if(complete[i]==-1)                 {                         printf(" #     |");                 }                 else                 {                         printf(" p%d ",complete[i]);                         int number=complete[i],h=0;                         for(;number>0;)                         {                                 h++;                                 number=number/10;                         }                         h=3-h;                         for(h;h>0;h--)                         {                                 printf(" ");                         }                         printf(" |");                 }                                  }         printf("\n");         printf(" ");         for(i=0;i<(z1*8)-1;i++)         {                 printf("-");         }         printf("\n");         printf("0");         for(i=0;i<z;i++)         {                 int number=cvalue[i],h=0;                 for(;number>0;)                 {                         h++;                         number=number/10;                 }                 h=3-h;                 printf("     ");                 for(h;h>0;h--)                 {                         printf(" ");                 }                 printf("%d",cvalue[i]);                                                   }         printf("\n\n");         printf("\t\tTable\n");         printf(" ");         for(i=0;i<56;i++)         {                 printf("-");         }         printf("\n");         printf("|\tPID\tAT\tBT\tCT\tTAT\tWT\t |\n");         printf(" ");         for(i=0;i<56;i++)         {                 printf("-");         }         printf("\n");                  // calculate turn-around time, waiting time of each process         for(i=0;i<np;i++)         {                 p_details[i].TAT=p_details[i].CT-p_details[i].AT;                 p_details[i].WT=p_details[i].TAT-p_details[i].BT1;                 Avg_TAT=Avg_TAT+p_details[i].TAT;                 Avg_WT=Avg_WT+p_details[i].WT;         }                  // print the table         for(i=0;i<np;i++)         {                 printf("|\t%d\t%d\t%d\t%d\t%d\t%d\t |\n",p_details[i].P_NO,p_details[i].AT,p_details[i].BT1,p_details[i].CT,p_details[i].TAT,p_details[i].WT);                 printf(" ");                 int j;                 for(j=0;j<56;j++)                 {                         printf("-");                 }                 printf("\n");         }         printf("\n");                  //calculate average waiting time, average turn-around time         Avg_TAT=Avg_TAT/np;         Avg_WT=Avg_WT/np;                  // calculate l value         l=(ctmax-atmin);                  // calculate throughput         Throughtput=np/l;                  // print average waiting time, average waiting time, l value, throughtput         printf("Avg_TAT=%.2f\nAvg_WT=%.2f\nl=%d\nThroughtput=%.2f\n",Avg_TAT,Avg_WT,(int)l,Throughtput);                               } Sample Input/Output rgukt-rkv@rguktrkv-TravelMate-P243-M: /Downloads/os labs programs/scheduling algorithms SRTF algorithm C code #include<stdio.h> #include<string.h> struct SRTF {         int P_NO,AT,BT,CT,WT,BT1,TAT,index; }; int main() {     // ask user to enter no.of processe         printf("Enter no.of processes: ");                  // declare an variable to store no.of processes, array to completion value of each process         int np,cvalue[100],s=0,complete[100],z1=0;                  // declare variable to store average turn-around time, average waiting time, throughput etc         float Avg_TAT=0,Avg_WT=0,ctmax,atmin,l,Throughput;                  // read no.of process from user         scanf("%d",&np);                  // declare a array of structures with size of no.of processes         struct SRTF p_details[np];                  // ask user to enter Process id, arrival time and burst time         printf("Enter PID and AT and BT for each process:\n");         int i;                   // read pid, arrival time, burst time for n processes         for(i=0;i<np;i++)         {                 scanf("%d%d%d",&p_details[i].P_NO,&p_details[i].AT,&p_details[i].BT);                 p_details[i].BT1=p_details[i].BT;         }         int c=0,v=0,f=0,y=0;         int status=0,z=0;                  // iterate for loop         for(i=0;i<np;)         {                 int j=0,t=0;                 f=0;                 while(j<np)                 {                         char ch=p_details[j].BT;                         if(ch!='.' && p_details[j].AT<=c)                         {                                 p_details[t].index=j;                                 t++;                                 f++;                         }       ... See the full answer