diff --git a/CPUscheduling/SRTF.c b/CPUscheduling/SRTF.c new file mode 100644 index 0000000..8fca395 --- /dev/null +++ b/CPUscheduling/SRTF.c @@ -0,0 +1,42 @@ +/* =================================== */ +/* ===== SRTF CPU Scheduling ===== */ +/* =================================== */ +#include +int main() +{ + int a[10],b[10],x[10],i,j,smallest,count=0,time,n; + double avg=0,tt=0,end; + printf("enter the number of Processes:\n"); + scanf("%d",&n); + printf("enter arrival time\n"); + for(i=0;i0 ) + smallest=i; + } + b[smallest]--; + if(b[smallest]==0) + { + count++; + end=time+1; + avg=avg+end-a[smallest]-x[smallest]; + tt= tt+end-a[smallest]; + } + } + printf("\n\nAverage waiting time = %lf\n",avg/n); + printf("Average Turnaround time = %lf",tt/n); + return 0; +} \ No newline at end of file