@@ -135,24 +135,21 @@ class SJF {
135
135
}
136
136
137
137
/* *
138
- * @brief Algorithm for scheduling CPU processes according to the Shortest Job
139
- First (SJF) scheduling algorithm.
140
- *
141
- * @details Non pre-emptive SJF is an algorithm that schedules processes based
142
- on the length
143
- * of their burst times. The process with the smallest burst time is executed
144
- first.
145
- * In a non-preemptive scheduling algorithm, once a process starts executing,
146
- * it runs to completion without being interrupted.
147
- *
148
- * I used a min priority queue because it allows you to efficiently pick the
149
- process
150
- * with the smallest burst time in constant time, by maintaining a priority
151
- order where
152
- * the shortest burst process is always at the front.
153
- *
154
- * @returns void
155
- */
138
+ * @brief Algorithm for scheduling CPU processes according to
139
+ * the Shortest Job First (SJF) scheduling algorithm.
140
+ *
141
+ * @details Non pre-emptive SJF is an algorithm that schedules processes
142
+ * based on the length of their burst times. The process with the smallest
143
+ * burst time is executed first.In a non-preemptive scheduling algorithm,
144
+ * once a process starts executing,it runs to completion without being
145
+ * interrupted.
146
+ *
147
+ * I used a min priority queue because it allows you to efficiently pick the
148
+ * process with the smallest burst time in constant time, by maintaining a
149
+ * priority order where the shortest burst process is always at the front.
150
+ *
151
+ * @returns void
152
+ */
156
153
157
154
vector<tuple<S, T, E, double , double , double >> scheduleForSJF () {
158
155
// Variable to keep track of time elapsed so far
@@ -192,8 +189,8 @@ class SJF {
192
189
return result;
193
190
}
194
191
/* *
195
- * @brief Utility function for printing the status of each process after
196
- * execution
192
+ * @brief Utility function for printing the status of
193
+ * each process after execution
197
194
* @returns void
198
195
*/
199
196
@@ -217,8 +214,8 @@ class SJF {
217
214
};
218
215
219
216
/* *
220
- * @brief Computes the final status of processes after applying non-preemptive
221
- * SJF scheduling
217
+ * @brief Computes the final status of processes after
218
+ * applying non-preemptive SJF scheduling
222
219
* @tparam S Data type of Process ID
223
220
* @tparam T Data type of Arrival time
224
221
* @tparam E Data type of Burst time
@@ -290,8 +287,8 @@ static void test() {
290
287
}
291
288
292
289
// Print processes before scheduling
293
- // cout << "Processes before SJF scheduling:" << endl;
294
- // readyQueue.printResult(input);
290
+ cout << " Processes before SJF scheduling:" << endl;
291
+ readyQueue.printResult (input);
295
292
296
293
// Add processes to the queue
297
294
for (uint32_t i{}; i < n; i++) {
@@ -303,8 +300,8 @@ static void test() {
303
300
auto finalResult = readyQueue.scheduleForSJF ();
304
301
305
302
// Print processes after scheduling
306
- // cout << "\nProcesses after SJF scheduling:" << endl;
307
- // readyQueue.printResult(finalResult);
303
+ cout << " \n Processes after SJF scheduling:" << endl;
304
+ readyQueue.printResult (finalResult);
308
305
}
309
306
cout << " All the tests have successfully passed!" << endl;
310
307
}
0 commit comments