Self-test implementations.
267 {
268
269 vector<tuple<uint32_t, uint32_t, uint32_t, double, double, double>>
270 finalResult;
271
272 for (int i{}; i < 10; i++) {
273 std::random_device rd;
274 std::mt19937 eng(rd());
275 std::uniform_int_distribution<> distr(1, 10);
276
277 uint32_t n = distr(eng);
279 vector<tuple<uint32_t, uint32_t, uint32_t, double, double, double>>
280 input(n);
281
282
283 for (uint32_t i{}; i < n; i++) {
284 get<0>(input[i]) = i;
285 get<1>(input[i]) = distr(eng);
286 get<2>(input[i]) = distr(eng);
287 }
288
289
290cout <<
"Processes before SJF scheduling:"<<
endl;
292
293
294 for (uint32_t i{}; i < n; i++) {
295readyQueue.
addProcess(get<0>(input[i]), get<1>(input[i]),
296 get<2>(input[i]));
297 }
298
299
301
302
303cout <<
"\nProcesses after SJF scheduling:"<<
endl;
305 }
306cout <<
"All the tests have successfully passed!"<<
endl;
307}
Class which implements the SJF scheduling algorithm.
void printResult(const vector< tuple< S, T, E, double, double, double > > &processes)
Utility function for printing the status of each process after execution.
vector< tuple< S, T, E, double, double, double > > scheduleForSJF()
Algorithm for scheduling CPU processes according to the Shortest Job First (SJF) scheduling algorithm...
void addProcess(S id, T arrival, E burst)
Adds the process to the ready queue if it isn't already there.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4