Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
71 lines (64 loc) · 2.4 KB
/
Copy pathmain.cpp
File metadata and controls
71 lines (64 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "sjf_non_preemptive.hpp"
#include "fcfs-non-preemptive.hpp"
#include "priority_non_preemptive.hpp"
#include "srtf_preemptive.hpp"
#include "round_robin.hpp"
#include "comparison_tool.hpp"
#include "scheduler_common.hpp"
#include <iostream>
#include <limits>
void display_menu() {
clearScreen();
std::cout << "|| CPU Scheduling Algorithm Simulator ||" << std::endl;
std::cout << "Select the option:" << std::endl;
std::cout << "1. Shortest Job First (SJF) Algorithm (Non-Preemptive)" << std::endl;
std::cout << "2. First-Come, First-Served (FCFS) Algorithm (Non-Preemptive)" << std::endl;
std::cout << "3. Priority Scheduling Algorithm (Non-Preemptive)" << std::endl;
std::cout << "4. Shortest Remaining Time First (SRTF) Algorithm (Preemptive)" << std::endl;
std::cout << "5. Round Robin (RR) Scheduling Algorithm (Preemptive)" << std::endl;
std::cout << "6. Compare All Algorithms (Fast Calculation)" << std::endl; // NEW OPTION
std::cout << "0. Exit" << std::endl;
std::cout << "Enter choice: ";
}
int main() {
int choice;
do {
display_menu();
if (!(std::cin >> choice)) {
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
choice = -1;
}
switch (choice) {
case 1:
run_sjf_non_preemptive_simulation();
break;
case 2:
run_fcfs_non_preemptive_simulation();
break;
case 3:
run_priority_non_preemptive_simulation();
break;
case 4:
run_srtf_preemptive_simulation();
break;
case 5:
run_round_robin_simulation();
break;
case 6: // NEW CASE
run_all_algorithms_comparison();
break;
case 0:
std::cout << "\nExiting the simulator. Goodbye!\n";
break;
default:
clearScreen();
std::cout << "Invalid choice. Please enter 1, 2, 3, 4, 5, 6, or 0.\n";
std::cout << "Press Enter to try again...";
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cin.get();
break;
}
} while (choice != 0);
return 0;
}