Function to be used for testing purposes. This function guarantees the correct solution for FCFS scheduling algorithm.
Sorts the input vector according to arrival time. Processes whose arrival times are same get sorted according to process ID For each process, completion time, turnaround time and completion time are calculated, inserted in a tuple, which is added to the vector result.
226 {
229 double timeElapsed = 0;
230 for (
size_t i{}; i < input.
size(); i++) {
231 T arrival = get<1>(input[i]);
232 E burst = get<2>(input[i]);
233
234 if (arrival > timeElapsed) {
235 timeElapsed += arrival - timeElapsed;
236 }
237 timeElapsed += burst;
238 double completion = timeElapsed;
239 double turnaround = completion - arrival;
240 double waiting = turnaround - burst;
241
242 get<0>(result[i]) = get<0>(input[i]);
243 get<1>(result[i]) = arrival;
244 get<2>(result[i]) = burst;
245 get<3>(result[i]) = completion;
246 get<4>(result[i]) = turnaround;
247 get<5>(result[i]) = waiting;
248 }
250}
bool sortcol(tuple< S, T, E > &t1, tuple< S, T, E > &t2)
Comparator function for sorting a vector.
Definition fcfs_scheduling.cpp:45
uint64_t result(uint64_t n)
Definition fibonacci_sum.cpp:76