Skip to content

Commit ee2b2e9

Browse files
Panquesito7Daemon19
authored andcommitted
clang-format and clang-tidy fixes for b6ff48c
1 parent 6d00a6b commit ee2b2e9

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

cpu_scheduling_algorithms/round_robin_scheduling.cpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
* @author [Daemon19](https://github.com/Daemon19)
1010
*/
1111

12-
#include <iomanip> /// For formatting process results output
13-
#include <cassert> /// For testing the round-robin algorithm
14-
#include <string> /// For converting int type to string
15-
#include <iostream> /// For outputting process execution results
16-
#include <queue> /// Container for process execution turn
17-
#include <set> /// Container for processes that have arrived
18-
#include <utility> /// So I can use std::pair
19-
#include <vector> /// Container for processes that will be executed
20-
#include <algorithm> /// So I can use std::sort
12+
#include <algorithm> /// So I can use std::sort
13+
#include <cassert> /// For testing the round-robin algorithm
14+
#include <iomanip> /// For formatting process results output
15+
#include <iostream> /// For outputting process execution results
16+
#include <queue> /// Container for process execution turn
17+
#include <set> /// Container for processes that have arrived
18+
#include <string> /// For converting int type to string
19+
#include <utility> /// So I can use std::pair
20+
#include <vector> /// Container for processes that will be executed
2121

2222
/**
2323
* @brief Represent a process to be executed.
@@ -32,8 +32,10 @@ struct Process {
3232
* @brief Represent the result of a process execution.
3333
*/
3434
struct ProcessResult : public Process {
35-
uint32_t completion_time; ///< The time at which the process execution is finished
36-
uint32_t turn_around_time; ///< The turn around time required for the process to complete
35+
uint32_t completion_time; ///< The time at which the process execution is
36+
///< finished
37+
uint32_t turn_around_time; ///< The turn around time required for the
38+
///< process to complete
3739
uint32_t waiting_time; ///< Process waiting time before execution
3840

3941
/**
@@ -95,7 +97,6 @@ std::ostream& operator<<(std::ostream& ostream,
9597
*/
9698
static void Test();
9799

98-
99100
/**
100101
* @brief Comparator function for sorting processes.
101102
*
@@ -170,10 +171,10 @@ std::vector<ProcessResult> RRExecute(const std::vector<Process>& processes,
170171

171172
// The time of the first process execution will be the lowest process AT
172173
uint32_t time_elapsed =
173-
std::min_element(processes.begin(), processes.end(), CompareAT)->arrival_time;
174+
std::min_element(processes.begin(), processes.end(), CompareAT)
175+
->arrival_time;
174176

175-
CheckArriveProcess(processes, &arrived_processes, &schedule,
176-
time_elapsed);
177+
CheckArriveProcess(processes, &arrived_processes, &schedule, time_elapsed);
177178

178179
while (!schedule.empty()) {
179180
std::pair<Process, BTLeft> current = schedule.front();
@@ -184,14 +185,14 @@ std::vector<ProcessResult> RRExecute(const std::vector<Process>& processes,
184185
// quantum/slice
185186
uint32_t elapsed =
186187
(current.second > time_slice) ? time_slice : current.second;
187-
current.second -= elapsed;
188-
time_elapsed += elapsed;
188+
current.second -= elapsed;
189+
time_elapsed += elapsed;
189190

190-
CheckArriveProcess(processes, &arrived_processes, &schedule,
191-
time_elapsed);
191+
CheckArriveProcess(processes, &arrived_processes, &schedule,
192+
time_elapsed);
192193

193194
if (current.second > 0) {
194-
schedule.push(current);
195+
schedule.push(current);
195196
continue;
196197
}
197198
// Generate process result based on the completion time (time
@@ -204,7 +205,7 @@ std::vector<ProcessResult> RRExecute(const std::vector<Process>& processes,
204205

205206
std::ostream& operator<<(std::ostream& ostream,
206207
const std::vector<ProcessResult>& results) {
207-
auto PrintCell = [&](const std::string &str) {
208+
auto PrintCell = [&](const std::string& str) {
208209
ostream << std::setw(17) << std::left << str;
209210
};
210211

@@ -232,7 +233,7 @@ std::ostream& operator<<(std::ostream& ostream,
232233
return ostream;
233234
}
234235

235-
void CheckArriveProcess(const std::vector<Process> &processes,
236+
void CheckArriveProcess(const std::vector<Process>& processes,
236237
std::set<uint32_t>* arrived_process,
237238
std::queue<std::pair<Process, BTLeft>>* schedule,
238239
uint32_t time_elapsed) {

0 commit comments

Comments
 (0)