Question

ROUND ROBIN TQ = 4 process number arrival time service time response waiting time total time context switches time P1 02 P24

Fill out both charts

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Round Robin:

Time Quantum (TQ): 4

Process Number Arrival Service Waiting Time Response Time Total Time Context Switches
P1 0 9 9 0 18 3
P2 4 5 8 4 13 2
P3 8 7 14 12 21 2
P4 14 7 11 18 18 2
P5 15 4 8 22 12 1

Gantt Chart

P1 P2 P1 P3 P2 P1 P4 P5 P3 P4

Program:

RoundRobin.cpp

#include<iostream>

using namespace std;

void SearchStack01(int pnt,int tm);

void SearchStack02(int pnt, int tm);

void AddQue(int pnt);

int at[50], bt[50], ct[50]={0}, qt, rqi[50]={0}, c=0, st, flg=0, tm=0, noe=0, pnt=0, btm[50]={0}, tt, wt;

float att, awt;

int main(){

cout<<"ROUND ROBIN ALGO : INPUT 5 PROCESSES\n";

for(int x=0;x<5;x++){

cout<<"\nProcess "<<x+1;

cout<<"\nArrival Time : ";

cin>>at[x];

cout << "\nSerivice Time : ";

cin>>bt[x];

btm[x]=bt[x];}

cout<<"\nEnter time quantum: ";

cin>>qt;


cout<<endl<<"GANTT CHART"<<endl<<at[0];

do{

if(flg==0){

st=at[0];

//---ReduceBT

if(btm[0]<=qt){

tm=st+btm[0];

btm[0]=0;

SearchStack01(pnt,tm);}

else{

btm[0]=btm[0]-qt;

tm=st+qt;

SearchStack01(pnt,tm);

AddQue(pnt);}

}//if

else{

pnt=rqi[0]-1;

st=tm;

//---DeleteQue

for(int x=0;x<noe && noe!=1;x++){

rqi[x]=rqi[x+1];}

noe--;

//---ReduceBT

if(btm[pnt]<=qt){

tm=st+btm[pnt];

btm[pnt]=0;

SearchStack02(pnt, tm);}

else{

btm[pnt]=btm[pnt]-qt;

tm=st+qt;

SearchStack02(pnt, tm);

AddQue(pnt);}

}//else

//AssignCTvalue

if(btm[pnt]==0){

ct[pnt]=tm;

}//if

flg++;

cout<<"]-P"<<pnt+1<<"-["<<tm;

}while(noe!=0);

cout<<"\n\nPROCESS\t Arrival Time: \t Service Time: \t Completion Time: \t Turn Around Time \t Wait Time\n";

for(int x=0;x<5;x++){

tt=ct[x]-at[x];

wt=tt-bt[x];

cout<<"P"<<x+1<<" \t\t\t "<<at[x]<<" \t\t\t "<<bt[x]<<" \t\t\t "<<ct[x]<<" \t\t\t "<<tt<<" \t\t\t "<<wt<<"\n";

awt=awt+wt;

att=att+tt;

}//for

cout<<"\nAVERAGE TT: "<<att/5<<"\nAVERAGE WT: "<<awt/5;

return 0;

}//main

void SearchStack01(int pnt,int tm){

for(int x=pnt+1;x<5;x++){

if(at[x]<=tm){

rqi[noe]=x+1;

noe++;}

}//for

}//void

void SearchStack02(int pnt, int tm){

for(int x=pnt+1;x<5;x++){

//---CheckQue

int fl=0;

for(int y=0;y<noe;y++){

if(rqi[y]==x+1){

fl++;}}

if(at[x]<=tm && fl==0 && btm[x]!=0){

rqi[noe]=x+1;

noe++;}

}//for

}//void

void AddQue(int pnt){

rqi[noe]=pnt+1;

noe++;

}//void

output:

ROUND ROBIN ALGO : INPUT 5 PROCESSES

Process 1
Arrival Time : 0

Serivice Time : 9

Process 2
Arrival Time : 4

Serivice Time : 5

Process 3
Arrival Time : 8

Serivice Time : 7

Process 4
Arrival Time : 14

Serivice Time : 7

Process 5
Arrival Time : 14

Serivice Time : 4

Enter time quantum: 4

GANTT CHART
0]-P1-[4]-P2-[8]-P1-[12]-P3-[16]-P2-[17]-P1-[18]-P4-[22]-P5-[26]-P3-[29]-P4-[32

PROCESS Arrival Time: Service Time: Completion Time: Turn AroundTime Wait Time
P1 0 9 18 18 9
P2 4 5 17 13 8
P3 8 7 29 21 14
P4 14 7 32 1811
P5 14 4 26 128

AVERAGE TT: 16.4
AVERAGE WT: 10

Add a comment
Know the answer?
Add Answer to:
Fill out both charts ROUND ROBIN TQ = 4 process number arrival time service time response...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • question is based on operating system concept. round roubin algorith 4 5 6 Use Round Robin...

    question is based on operating system concept. round roubin algorith 4 5 6 Use Round Robin algorithm with a time quantum of 5 7 proc arrival service num time time 8 9 waiting time response time total time context switches P1 0 12 P2 5 10 11 12 13 14 P3 10 9 PA 14 5 8 Ps 21 15 16 Fill in the two charts (above and below) 17 18 19 20 21 22 23 24 25 26 27...

  • Part 2 Round Robin Scheduling Process Burst Time in Ms P1 4 P2 2 P3 1...

    Part 2 Round Robin Scheduling Process Burst Time in Ms P1 4 P2 2 P3 1 Calculate the average waiting time and turnaround time using round robin scheduling, where the time quantum q = 2 ms According to the Round Robin algorithm, the arrival of processes is shown in the following Gantt chart. P1 P2 P3 P1 P2 P3 P1 P2 P3 P1 0                 2                 4                  6                8                 10               12                14               15              16               18...

  • Solve by Round Robin Scheduling, Quantum = 3 (preemptive). Calculate the average waiting time: Process Arrival...

    Solve by Round Robin Scheduling, Quantum = 3 (preemptive). Calculate the average waiting time: Process Arrival Time Execution Time РО 5 P1 1 3 P2 N 8 P3 3 6

  • 2- Consider the following set of processes: Arrival Time Process Service Time 10 Find the average response, wait and tu...

    2- Consider the following set of processes: Arrival Time Process Service Time 10 Find the average response, wait and turnaround times of the processes in FCFS, Round Robin (with Q-2), SPN and SRT, MLFD (with q-2') and HRRN algorithms. 2- Consider the following set of processes: Arrival Time Process Service Time 10 Find the average response, wait and turnaround times of the processes in FCFS, Round Robin (with Q-2), SPN and SRT, MLFD (with q-2') and HRRN algorithms.

  • V. Round Robin and SJF comparison 6 Process Arrival Time CPU Burst Time P1 0 9...

    V. Round Robin and SJF comparison 6 Process Arrival Time CPU Burst Time P1 0 9 P2 4 4 P3 6 P4 For each of the following algorithms, draw a Gantt chart and calculate the average wait time and turn around time. 1. Round robin with quantum=1 time unit 2. Round-robin with quantum=3 time-units 3. SJF WI preemption (Shortest Remaining Time First), assume quantum=3 4. SJE Wlo preemption 5. ECES

  •          Process                    Arrival Time            &nbsp

             Process                    Arrival Time                             Burst Time                         P1                                0                                              2                         P2                                1                                              1                         P3                                2                                              4                         P4                                3                                              2                         P5                                4                                              1 Consider a set of processes given above with the arrival time and the length of CPU burst time given in cycles. Show a Gantt chart and calculations of average turnaround time and average waiting time of these processes under the shortest job first (SJF) with preemption CPU scheduling algorithm and the round-robin...

  • 4. Consider a ready queue with four processes :- Process Arrival Time Burst Time (ms) P1...

    4. Consider a ready queue with four processes :- Process Arrival Time Burst Time (ms) P1 Priority P2 P3 P4 P5 For each of the following CPU scheduling algorithms, determine the turnaround and average waiting time for each of the process :- a. Shortest remaining Time First b. Shortest Job First C. Priority Scheduling (Both pre-emptive and non-preemptive) d. Round Robin (quantum is 1 ms)

  • Given the following set of processes---with the specified length of the CPU burst, arrival time, and...

    Given the following set of processes---with the specified length of the CPU burst, arrival time, and priority---compute response time for P1-P5 with round-robin scheduling with time quantum of 10 units. Also compute average response time. Assume that a newly arriving process arrives first at time T- and a process that is preempted due to the completion of its quantum arrives at time T+ in the waiting queue. (Note: Show the Gantt chart and other working details in your worksheet.) Process...

  • Can you please choose the correct answer arrival time Bust time pl for the above table,...

    Can you please choose the correct answer arrival time Bust time pl for the above table, under FCFS scheduling, processes are scheduled as follows: a. pl, p4, p2, p3 b. pl, p2, p4, p3 c. pl, p2, p3, p4 d. p2, p4, p3, pl arrival time Bust time 13 for the above table, under SJF scheduling, processes are scheduled as follows c. d. p3, pl, p4, p3 X pl, p3, p4, p2 pl, p3, p2, arrival time Bust time 13...

  • Assume that you have four different processes with the following attributes: Process   Arrival time.   CPU Burst....

    Assume that you have four different processes with the following attributes: Process   Arrival time.   CPU Burst.   I/O Burst Total CPU time A. 0 4 4 9 B 3 2 3 7 C 6 5 1 11 D 12 1 1 5 As we did in class, perform a scheduling simulation using these four processes according to the following algorithms: 1) First Come First Serve 2) Round Robin with time slice = 1 3) Round Robin with time slice = 3...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT