-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
53 lines (42 loc) · 1.91 KB
/
main.cpp
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
#include <iostream>
#include "algorithms.cpp"
#include "PCB.h"
#include "PCBFuns.h"
using namespace std;
int main(){
vector<PCB> processes;
pair<int, vector<PCB>> result ;
int contextSwitch, quantum, processesNum;
processesNum = 3;
readFromFile("processes/FCFS.txt", processesNum, processes, contextSwitch, quantum);
cout << endl << "• First Come First Serve Algorithm (FCFS) •" << endl << endl;
result = FCFS(processes, contextSwitch);
printPCBInfo(result.second);
calculateStatistics(result.second, result.first, processesNum);
processes.clear();
cout << "------------------------------------------------------------" << endl << endl;
processesNum = 4;
readFromFile("processes/SRT.txt", processesNum, processes, contextSwitch, quantum);
cout <<"• Shortest Remaining Time First (SRT) •" << endl << endl;
result = SRT(processes, contextSwitch);
printPCBInfo(result.second);
calculateStatistics(result.second, result.first, processesNum);
processes.clear();
cout << "------------------------------------------------------------" << endl << endl;
processesNum = 3;
readFromFile("processes/RR.txt", processesNum, processes, contextSwitch, quantum);
cout <<"• Round Robin algorithm (RR) •" << endl << endl;
result = RR(quantum ,processes, contextSwitch);
printPCBInfo(result.second);
calculateStatistics(result.second, result.first, processesNum);
processes.clear();
cout << "------------------------------------------------------------" << endl << endl;
processesNum = 4;
readFromFile("processes/SJF.txt", processesNum, processes, contextSwitch, quantum);
cout <<"• Shortest Job First Algorithm (SJF) •" << endl << endl;
result = SJF(processes, contextSwitch);
printPCBInfo(result.second);
calculateStatistics(result.second, result.first, processesNum);
processes.clear();
return 0;
}