Solve FCFSNON PREMPTIVE for the following process and calcu
Solve FCFS(NON - PREMPTIVE) for the following process and calculate :
Please show work so I can understand this., Can you also mention how we take into account i/o time.
U (CPU utilization),
WT (waiting times)
TT (turnaround times),
RT(response times)
AVG WT (avg waiting times)
AVG TT (avg turnaround times),
AVG RT(avg response times)
Process Data:
process goes {CPU burst, I/O time, CPU burst, I/O time, CPU burst, I/O time,…….., last CPU burst}
P1 {4,24,5,73,3,31,5,27,4,33,6,43,4,64,5,19,2}
P2 {18,31,19,35,11,42,18,43,19,47,18,43,17,51,19,32,10}
P3 {6,18,4,21,7,19,4,16,5,29,7,21,8,22,6,24,5}
P4 {17,42,19,55,20,54,17,52,15,67,12,72,15,66,14}
P5 {5,81,4,82,5,71,3,61,5,62,4,51,3,77,4,61,3,42,5}
P6 {10,35,12,41,14,33,11,32,15,41,13,29,11}
P7 {21,51,23,53,24,61,22,31,21,43,20}
P8 {11,52,14,42,15,31,17,21,16,43,12,31,13,32,15}
Solution
Kindly use the below C++ program to calculate the required timings:
#include<iostream>
 
 using namespace std;
 
 int main()
 {
 int n,bursttime[20],waitingtime[20],turnaroundtime[20],avwaitingtime=0,avturnaroundtime=0,i,j;
  cout<<\"Enter total number of processes:\";
 cin>>n;
 
 cout<<\"\ Enter Process Burst Time\ \";
 for(i=0;i<n;i++)
 {
 cout<<\"P[\"<<i+1<<\"]:\";
 cin>>bursttime[i];
 }
 
 waitingtime[0]=0; //waiting time for first process is 0 in our case
 
 //calculating waiting time
 for(i=1;i<n;i++)
 {
 waitingtime[i]=0;
 for(j=0;j<i;j++)
 waitingtime[i]+=bursttime[j];
 }
 
 cout<<\"\ Process\\t\\tBurst Time\\tWaiting Time\\tTurnaround Time\";
 
 //calculating turnaround time
 for(i=0;i<n;i++)
 {
 turnaroundtime[i]=bursttime[i]+waitingtime[i];
 avwaitingtime+=waitingtime[i];
 avturnaroundtime+=turnaroundtime[i];
 cout<<\"\ P[\"<<i+1<<\"]\"<<\"\\t\\t\"<<bursttime[i]<<\"\\t\\t\"<<waitingtime[i]<<\"\\t\\t\"<<turnaroundtime[i];
  }
 
 avwaitingtime/=i;
 avturnaroundtime/=i;
 cout<<\"\ \ Average Waiting Time:\"<<avwaitingtime;
 cout<<\"\ Average Turnaround Time:\"<<avturnaroundtime;
 
 return 0;
 }
The results are as below:
Avg Wait time (WT) - 285.875
Avg Turnaround time (TT) - 691.5
Avg Response time (RT) - 36.25
CPU utilization - 82.02%
CPU utilization is maximized by running long-running CPU-bound tasks without performing context switches. I/O device utilization is maximized by scheduling I/O-bound jobs as soon as they become ready to run, thereby incurring the overheads of context switches.
Hope this helps :)


