-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (49 loc) · 1.3 KB
/
main.cpp
File metadata and controls
56 lines (49 loc) · 1.3 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
#include <iostream>
#include <stdlib.h>
#include "SRTF.h"
#include "FCFS.h"
#include "scheduler.h"
#include "RR.h"
using namespace std;
int main(int argc, char *argv[]) {
string inputFile;
string scheduler;
int timeQuantum;
// Check for minimum arguments to run
if (argc < 3) {
cout << "You are missing some arguments." << endl;
return 0;
}
inputFile = argv[1];
scheduler = argv[2];
// Determine scheduler algorithm to run
if (scheduler == "FCFS") {
cout << "Scheduling algorithm: " << scheduler << endl;
FCFS fcfsObj(inputFile);
fcfsObj.runScheduler();
fcfsObj.printProcessResult();
}
else if (scheduler == "RR") {
cout << "Scheduling algorithm: " << scheduler << endl;
if (argc < 4) {
cout << "You are missing the time quantum argument." << endl;
return 0;
} else {
timeQuantum = atoi(argv[3]);
}
// Run RR Process
RR RRobj(inputFile, timeQuantum);
RRobj.runScheduler();
RRobj.printProcessResult();
}
else if (scheduler == "SRTF") {
cout << "Scheduling algorithm: " << scheduler << endl;
SRTF srtfObj(inputFile);
srtfObj.runScheduler();
srtfObj.printProcessResult();
}
else {
cout << "Invalid scheduler name. Exiting program..." << endl;
}
return 0;
}