Question
this is the round robin algorithm implemented using C++ in need each line in this code to be explained please #include using namespace std; int
this is the round robin algorithm implemented using C++ in need each line in this code to be explained please
#include
using namespace std;
int main(){ int i,j,k=0,p=0,q,temp,s=0,idle=0,done=0; float sum=0; cout<<"Please enter the number of proces : "; cin>>p; int a[p][4]; int b[p][5]; cout<<"Please enter the Time Quantum : "; cin>>q; cout<<" Process\tArrival\tBurst -------\t-------\t----- "; for(i=0;i
>a[i][j]; } a[i][3]=a[i][2]; } cout<<" Time-Line is as follows (Verticle View).... "; i=a[0][1]; while(done!=p){ if(k==p) k=0; if(a[k][1]<=i){ if(a[k][2]!=0){ if(a[k][2]>=q){ printf("%5d----------- |p-%-4d| ",i,a[k][0]); a[k][2]-=q; i+=q; } else{ printf("%5d----------- |p-%-4d| ",i,a[k][0]); i+=a[k][2]; a[k][2]=0; } if(a[k][2]==0){ b[s][0]=a[k][0]; b[s][1]=a[k][1]; b[s][2]=i; b[s][3]=a[k][3]; b[s][4]=((i-a[k][1])-a[k][3]); sum+=((i-a[k][1])-a[k][3]); s++; done++; } idle=0; } k++; } else{ if(idle==0){ idle=1; k=0; } else if(idle==1){ printf("%5d----------- |Idle| ",i); idle=2; i++; } else i++; } } printf("%5d-----------\t",i); cout< There are 3 Steps involved in it See step-by-step solutions with expert insights and AI powered tools for academic successStep by Step Solution
Step: 1
Get Instant Access to Expert-Tailored Solutions
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started