Added comments for member variables of FCFS class

This commit is contained in:
Pratyush219 2021-10-06 20:13:21 +05:30
parent b62916254f
commit ffd979e9c5
2 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}

View File

@ -40,6 +40,7 @@ class Compare{
template<typename S, typename T, typename E>
class FCFS{
/**
* Priority queue of schedules(stored as tuples) of processes.
* In each tuple
* 1st element: Process id
* 2nd element: Arrival Time
@ -49,10 +50,22 @@ class FCFS{
* 6th element: Waiting time
*/
priority_queue<tuple<S, T, E, double, double, double>, vector<tuple<S, T, E, double, double, double>>, Compare<S, T, E>> schedule;
vector<tuple<S, T, E, double, double, double>> result;
// Stores final status of all the processes after completing execution.
vector<tuple<S, T, E, double, double, double>> result;
// Stores process ids. Used for confirming absence of a process while adding it.
unordered_set<S> idList;
public:
/**
* @brief add the process to the ready queue if it isn't already there
* @param id: Process id
* @param arrival: Arrival time of the process
* @param burst: Burst time of the process
*
*/
void addProcess(S id, T arrival, E burst){
// Add if process with process id not found in idList.
if(idList.find(id) == idList.end()) {
tuple<S, T, E, double, double, double> t = make_tuple(id, arrival, burst, 0, 0, 0);
schedule.push(t);