A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d7/d1a/non__preemptive__sjf__scheduling_8cpp.html below:

TheAlgorithms/C++: cpu_scheduling_algorithms/non_preemptive_sjf_scheduling.cpp File Reference

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

290

cout <<

"Processes before SJF scheduling:"

<<

endl

;

292

293

294 for (uint32_t i{}; i < n; i++) {

295

readyQueue.

addProcess

(get<0>(input[i]), get<1>(input[i]),

296 get<2>(input[i]));

297 }

298

299

301

302

303

cout <<

"\nProcesses after SJF scheduling:"

<<

endl

;

305 }

306

cout <<

"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