TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Implementation of FCFS CPU scheduling algorithm. More...
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <queue>
#include <unordered_set>
#include <vector>
Go to the source code of this file.
Classes | |
class | Compare< S, T, E > |
Comparator class for priority queue. More... | |
class | FCFS< S, T, E > |
Class which implements the FCFS scheduling algorithm. More... | |
Functions | |
template<typename S , typename T , typename E > | |
bool | sortcol (tuple< S, T, E > &t1, tuple< S, T, E > &t2) |
Comparator function for sorting a vector. | |
template<typename S , typename T , typename E > | |
vector< tuple< S, T, E, double, double, double > > | get_final_status (vector< tuple< uint32_t, uint32_t, uint32_t > > input) |
Function to be used for testing purposes. This function guarantees the correct solution for FCFS scheduling algorithm. | |
static void | test () |
Self-test implementations. | |
int | main () |
Entry point of the program. | |
Implementation of FCFS CPU scheduling algorithm.
FCFS is a non-preemptive CPU scheduling algorithm in which whichever process arrives first, gets executed first. If two or more processes arrive simultaneously, the process with smaller process ID gets executed first. https://bit.ly/3ABNXOCPratyush Vatsa
Definition in file fcfs_scheduling.cpp.
vector< tuple< S, T, E, double, double, double > > get_final_status | ( | vector< tuple< uint32_t, uint32_t, uint32_t > > | input | ) |
Function to be used for testing purposes. This function guarantees the correct solution for FCFS scheduling algorithm.
input | the input data |
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.
Definition at line 226 of file fcfs_scheduling.cpp.
int main | ( | void | ) |
Entry point of the program.
Definition at line 288 of file fcfs_scheduling.cpp.
bool sortcol | ( | tuple< S, T, E > & | t1, |
tuple< S, T, E > & | t2 ) |
Comparator function for sorting a vector.
S | Data type of Process ID |
T | Data type of Arrival time |
E | Data type of Burst time |
t1 | First tuple |
t2 | Second tuple |
Definition at line 46 of file fcfs_scheduling.cpp.
|
static |
Self-test implementations.
Definition at line 257 of file fcfs_scheduling.cpp.