Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include first _ come _ first _ served.hpp #include namespace cse 4 7 3 3 { void first _ come _ first _ served::run

#include "first_come_first_served.hpp"
#include
namespace cse4733{
void first_come_first_served::run(std::vector>& processes)
{
// TODO:
//
// For all processes
// Get the arrival time
// Get the burst time
// If the arrival time is greater than the completion time
// Set the completion time to the arrival time
// Set the waiting time to the completion time minus the arrival time
// Set the completion time to the completion time plus the burst time
// Set the turnaround time to the completion time minus the arrival time
// Add the burst time to the current time
}
void first_come_first_served::print_results(std::vector>& processes){
std::cout <<"FCFS Scheduling:" << std::endl
<<" Process ID\tCompletion Time\tBurst Time\tArrival Time\tWaiting Time\tTurnaround Time" << std::endl;
int total_waiting =0;
int total_turnaround =0;
for (const auto& item : processes){
std::cout <<""<< item->to_string()<< std::endl;
total_waiting += item->get_waiting_time();
total_turnaround += item->get_turnaround_time();
}
std::cout <<" Average waiting time (tics): "<< total_waiting / processes.size()<< std::endl;
std::cout <<" Average turnaround time (tics): "<< total_turnaround / processes.size()<< std::endl << std::endl;
}
}

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