Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have this program below *****would you please adjust the following program that it can satisfy all what the question is asking for ********Include 2

I have this program below

*****would you please adjust the following program that it can satisfy all what the question is asking for

********Include 2 runs of the program. please include the screenshots

Write a program in c++ or java that simulates the FCFS (first-come, first-served), SJF (shortest-job-first), SRTF (shortest-remaining-time-first), RR (round-robin) and Priority CPU scheduling algorithms. Create a separate Class for the jobs. Each job has a ID, Arrival time, Burst Time, and Priority. Randomly generate the job details for 10 jobs (the IDs should be generated in a sequence i.e., ID#1, ID#2, , ID#10). Arrival time should be between 0 and 10, Burst time between 1 and 20 seconds, and priority between 1 and 10 (lower value has higher priority i.e., 1 has more priority than 5). For jobs with the same priority, give preference to arrival time. For the RR scheduling, assume the time quantum or time slice to be 3 seconds. Execute the same set of jobs for each of the algorithms. Report the average waiting time and average turnaround time for each scheduling algorithm. The program can be implemented either in C++ or Java. Submit a pdf including screenshots of the program in execution. Include 2 runs of the program. please include the screenshots

#include #include using namespace std; int number,id=0,quantum; struct st { int id,start,finish,arrival_time,service_time,service_time2,turnaround_time,waiting_time,last_run,priority; }job[50]; vectorv,v2; void sort_by_arrival_time(); void sort_by_service_time(); void sort_by_priority(); void drawline(int,int); void FCFS(void); void SJF(void); void SRTF(void); void Priority_scheduling(void); void Round_Robin(void); void show_diagram(); int show_output(); void gotoxy(int x,int y) { printf("%c[%d;%df",0x1B,y,x); } void sleep(unsigned int ms) { clock_t goal=ms+clock(); while(goal>clock()); } void intput1(void) { int x=5,y=10,i; gotoxy(x+3,y); cout<<"Process"; gotoxy(x+15,y); cout<<"Arrival time"; gotoxy(x+30,y); cout<<"Service time"; drawline(11,45); x=8;y=11; for(i=1;i<=number;i++) { gotoxy(x,y+i); cout<<"P"<=quantum) { d=0; cout<<"| "<

while(1) { system("clear"); //change made by reyan v.clear(); v2.clear(); cout<<"Job Scheduling algorithm list:"<>choice; if(choice==0) break; else if(choice<0||choice>5) { cout<<" Sorry wrong choice. Please try again."<>number; if(choice==1) { intput1(); sleep(5000); FCFS(); system("clear"); x=20;y=2; gotoxy(x,y); cout<<"First Come First Served (FCFS) job scheduling."<0) { idx=j; break; } } if(idx!=-1) { for(j=1;j<=number;j++) { if(job[j].arrival_time<=i&&job[j].service_time>0&&job[j].service_timeQ; int i,cnt; for(i=1;i<=number;i++) { Q.push_back(i); job[i].last_run=-1; job[i].waiting_time=0; } cnt=0; while(!Q.empty()) { i=Q.front(); Q.pop_front(); if(job[i].last_run==-1) { job[i].waiting_time=cnt; } else { job[i].waiting_time+=cnt-job[i].last_run; } if(job[i].service_time>quantum) { job[i].service_time-=quantum; job[i].last_run=quantum+cnt; Q.push_back(i); cnt+=quantum; for(int j=0;jjob[j].arrival_time) { temp=job[i]; job[i]=job[j]; job[j]=temp; } else if(job[i].arrival_time==job[j].arrival_time) { if(job[i].id>job[j].id) { temp=job[i]; job[i]=job[j]; job[j]=temp; } } } } } void sort_by_service_time(void) { int i,j; st temp; for(i=1;i<=number;i++) { for(j=i+1;j<=number;j++) { if(job[i].service_time>job[j].service_time) { temp=job[i]; job[i]=job[j]; job[j]=temp; } else if(job[i].service_time==job[j].service_time) { if(job[i].arrival_timejob[j].priority) { temp=job[i]; job[i]=job[j]; job[j]=temp; } else if(job[i].priority==job[j].priority) { if(job[i].id>job[j].id) { temp=job[i]; job[i]=job[j]; job[j]=temp; } } } } }

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_2

Step: 3

blur-text-image_3

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions

Question

A highly placed source explained the top secret negotiations.

Answered: 1 week ago

Question

Theyre selling a well designed machine.

Answered: 1 week ago