Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Generative Artificial Intelligence For Project Management With Aws

Authors: Timothy Krimmel

1st Edition

B0CQV9KWB8, 979-8872627197

More Books

Students also viewed these Databases questions

Question

=+ B-2 Describe descriptive statistics.

Answered: 1 week ago

Question

2. (1 point) Given AABC, tan A b b

Answered: 1 week ago