From ffd979e9c5f8db12e1e484245222444b89dac3bd Mon Sep 17 00:00:00 2001 From: Pratyush219 Date: Wed, 6 Oct 2021 20:13:21 +0530 Subject: [PATCH] Added comments for member variables of FCFS class --- .../.vscode/c_cpp_properties.json | 20 +++++++++++++++++++ .../scheduling_algorithms/fcfs_scheduling.cpp | 15 +++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 operating_system/scheduling_algorithms/.vscode/c_cpp_properties.json diff --git a/operating_system/scheduling_algorithms/.vscode/c_cpp_properties.json b/operating_system/scheduling_algorithms/.vscode/c_cpp_properties.json new file mode 100644 index 000000000..f5c17bce0 --- /dev/null +++ b/operating_system/scheduling_algorithms/.vscode/c_cpp_properties.json @@ -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 +} \ No newline at end of file diff --git a/operating_system/scheduling_algorithms/fcfs_scheduling.cpp b/operating_system/scheduling_algorithms/fcfs_scheduling.cpp index c348c04b5..a32f7521e 100644 --- a/operating_system/scheduling_algorithms/fcfs_scheduling.cpp +++ b/operating_system/scheduling_algorithms/fcfs_scheduling.cpp @@ -40,6 +40,7 @@ class Compare{ template 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, vector>, Compare> schedule; - vector> result; + + // Stores final status of all the processes after completing execution. + vector> result; + + // Stores process ids. Used for confirming absence of a process while adding it. unordered_set 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 t = make_tuple(id, arrival, burst, 0, 0, 0); schedule.push(t);