Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// C++ program for implementation of RR #include using namespace std; //function to find the waiting time for all //processes void findWaitingTime(int process[],int n, int

// C++ program for implementation of RR

#include using namespace std; //function to find the waiting time for all //processes

void findWaitingTime(int process[],int n, int bt[], int wt[], int quantum){ //make a copy of burst times bt[] to store remaining //burst time int rem_bt[n]; for (int i=0;i0){//if burst time of a process is greater than 0 then only need to process further done=false;//there is a pending process if(rem_bt[i]>quantum){ int t; t+=quantum;//increase the value of t i.e shows how much time a process has been processed rem_bt[i]-=quantum;//decrease the burst_time of current process by quantum } else{//if burst time is smaller than or equal to quantum. last cycle for this process int t; t=t+rem_bt[i];//increase the value of t i.e shows how much time a process has been processed wt[i]=t-bt[i];//waiting time is current time minus time useed by this process rem_bt[i]=0;//as the process gets fully executed make its remaining burst time=0 } } }//if all process are done if (done==true) break; } }

//function to calculate turn around time void findTurnAroundTime(int process[],int n ,int bt[], int tat,int quantum){ int wt[n], tat[n], total_wt=0, total_tat=0; findWaitingTime(process,n,bt,wt,quantum);//function to find waiting time of all processes findTurnAroundTime(process,n,bt,wt,tat);//function to find turn around time of all processes cou<<"PN\t"<<"\tBT"<<"WT"<<"\tTAT "//display processes along with all details for(int i=0;i){ //calculate total waiting time and total run around time total_wt=total_wt + wt[i]; total_tat=total_tat + tat[i]; cout<<""<

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions