mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Added comments for member variables of FCFS class
This commit is contained in:
parent
b62916254f
commit
ffd979e9c5
20
operating_system/scheduling_algorithms/.vscode/c_cpp_properties.json
vendored
Normal file
20
operating_system/scheduling_algorithms/.vscode/c_cpp_properties.json
vendored
Normal 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
|
||||||
|
}
|
@ -40,6 +40,7 @@ class Compare{
|
|||||||
template<typename S, typename T, typename E>
|
template<typename S, typename T, typename E>
|
||||||
class FCFS{
|
class FCFS{
|
||||||
/**
|
/**
|
||||||
|
* Priority queue of schedules(stored as tuples) of processes.
|
||||||
* In each tuple
|
* In each tuple
|
||||||
* 1st element: Process id
|
* 1st element: Process id
|
||||||
* 2nd element: Arrival Time
|
* 2nd element: Arrival Time
|
||||||
@ -49,10 +50,22 @@ class FCFS{
|
|||||||
* 6th element: Waiting time
|
* 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;
|
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;
|
unordered_set<S> idList;
|
||||||
public:
|
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){
|
void addProcess(S id, T arrival, E burst){
|
||||||
|
// Add if process with process id not found in idList.
|
||||||
if(idList.find(id) == idList.end()) {
|
if(idList.find(id) == idList.end()) {
|
||||||
tuple<S, T, E, double, double, double> t = make_tuple(id, arrival, burst, 0, 0, 0);
|
tuple<S, T, E, double, double, double> t = make_tuple(id, arrival, burst, 0, 0, 0);
|
||||||
schedule.push(t);
|
schedule.push(t);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user