#include main() { int i,wa=0,cumx[30],b[30],count=0,wait[30],k,x[30],xx[30]; int a,t=0,e,c,n,b1[30],max=0,wt=0,s,j; system("clear"); printf("\n \t Round Robin Scheduling:"); printf("\n Enter the number of jobs:"); scanf("%d",&n); for(i=0;i<20;i++) { xx[i]=-1; wait[i]=0; } for(i=0;i { printf("\n Enter the bursttime for job %d:",i+1); scanf("%d",&b[i]); b1[i]=b[i]; max=max>b[i]?max:b[i]; } printf("\n Enter the timeslice for jobs:"); scanf("%d",&s); k=1; for(j=0;j { printf("\n \t Job \t Exectime \t Remainingtime"); for(i=0;i { if(b[i]==0) continue; if(b[i] { a=b[i]; x[k]=i; xx[k]=b[i]; k++; } else { a=s; x[k]=i; xx[k]=s; k++; } b[i]-=a; printf("\n \t %d \t\t %d \t\t %d",i+1,a,b[i]); } printf("\n\n"); } for(i=1;i<=k;i++) count+=1; cumx[1]=0; for(i=2;i<=count;i++) { cumx[i]=xx[i-1]+cumx[i-1]; printf("%d ",cumx[i]); } for(j=0;j for(i=count-1;i>=1;i--) if(x[i]==j) { wait[j]=cumx[i+1]-b1[j]; t=t+cumx[i+1]; break; } printf("\n Waiting Time \n"); for(i=0;i { printf("%d\n",wait[i]); wa+=wait[i]; } printf("\n Average Waiting time is ,%f",(float)wa/n); printf("\n Average Executuion time is ,%f",(float)t/n); wt=wa+t; printf("\n Average turnaround time is ,%f",(float)wt/n); }
|
No responses found. Be the first to respond and make money from revenue sharing program.
|