Question: Write a scheduler and simulate one scheduler. I think it is like performing one task or something (im not sure if reading from file would

Write a scheduler and simulate one scheduler. I think it is like performing one task or something (im not sure if reading from file would be similar to it or not) using Java. Also using fixed priority

I believe it would be similar to this program.

Write a working simulation of a round robin scheduler.

#include

using namespace std;

int main()

{

int k,j,q,i,n,ts,temp;

int aw; float awt;

int bt[10],wt[10],te[10],rt[10],at[10];j=0; //te array stores the number of times a process comes to CPU before completion

//bt is my burst time store array

//wt is my waiting time array

//te keeps a count of the number of times a process enters the CPU before completion

//at is the arrival time

cout<<"Enter number of processes"<

cin>>n;

for(i=0;i

{

cout<<"Enter burst time"<

cin>>bt[i];

cout<<"Enter arrival times"<

cin>>at[i];

te[i] = 0; wt[i] = 0;

}

for(i=0;i

{

for(j = i+1;j

{

if(at[j]

{

temp = at[i];

at[i] = at[j];

at[j] = temp;

if(at[j] ==at[i])

temp = bt[i];

bt[i] = bt[j];

bt[j] = temp;

}

}

}

cout<<"Enter time slice"<

cin>>ts;

cout<<"process:"<

for(i=0;i

{

cout<<"\t"<

}

cout<<"Burst time:"<

for(i=0;i

{

cout<<" "<

rt[i] = bt[i];

}

cout<<"arrival time:"<

for(i=0;i

{

cout<<" "<

}

cout<<"Gaint chart"<

while (j<=n)

{

j++;

for(i = 0;i

{

if(rt[i] ==0) continue;

if(rt[i]>=ts)

{

cout<<"\t"<

q = q + ts;

rt[i] = rt[i] - ts;

te[i] = te[i] + 1;

}

else

{

cout<<" "<

wt[i] = q-te[i]*ts;

q = q +rt[i];

rt[i] = rt[i] - rt[i];

}

}

}

awt = 0;

cout<<"Process Waiting Time"<

for(i =0;i

{

wt[i] = wt[i] - at[i];

cout<<" "<

cout<

awt = awt + wt[i];

}

aw = awt;

cout<<"Total waiting time"<

cout<<"Average waiting time "<

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!