-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab4-jinglun-dong.cpp
64 lines (61 loc) · 1.5 KB
/
lab4-jinglun-dong.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
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include "Proc.h"
#include "Pager.h"
using namespace std;
int main(int argc, char* argv[]) {
int machineSize = 0;
int pageSize = 0;
int processSize = 0;
int jobMix = 0;
int numRefPerProc = 0;
RepAlgo repAlgo;
bool debugFlag = false;
bool showRandom = false;
int debugLevel = 0;
string str_debugLevel, str_argv;
if (argc >=7){
machineSize = atoi(argv[1]);
pageSize = atoi(argv[2]);
processSize = atoi(argv[3]);
jobMix = atoi(argv[4]);
numRefPerProc = atoi(argv[5]);
str_argv.assign(argv[6]);
if (!str_argv.compare(string("fifo"))){
repAlgo = fifo;
}
if (!str_argv.compare(string("random"))){
repAlgo = randomAlgo;
}
if (!str_argv.compare(string("lru"))){
repAlgo = lru;
}
if (argc >= 8){
debugLevel = atoi(argv[7]);
if (debugLevel == 1){
debugFlag = true;
showRandom = false;
}
else {
if (debugLevel ==2){
debugFlag = true;
showRandom = true;
}
}
}
}
Pager pager (machineSize, pageSize, processSize, jobMix, numRefPerProc, repAlgo, debugFlag, showRandom);
pager.summarizeHead();
pager.paging();
pager.summarizedTail();
//cout<<machineSize<<"\n"<<pageSize<<"\n"
// <<processSize<<"\n"<<jobMix<<"\n"<<numRefPerProc<<"\n"
// <<repAlgo<<"\n";
//cout<<"argc:"<<argc<<"\n";
//cout<<"debugFlag:"<<(int)debugFlag<<"showRandom"<<(int)showRandom<<"\n";
//cout<<debugLevel;
return 0;
}