-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpagereplacementfifo.cpp
More file actions
47 lines (41 loc) · 901 Bytes
/
pagereplacementfifo.cpp
File metadata and controls
47 lines (41 loc) · 901 Bytes
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
#include <iostream>
using namespace std;
int main()
{
int reference_string[20] = {7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1};
int frame[3]={-1,-1,-1};
int miss = 0;
int hit = 0;
int *rear;
int i = 0;
int search;
int index = 0;
int j = 0;
int k = 0;
for (i = 0; i <= 20; i++)
{
search = reference_string[i];
int count = 0;
int flag = 0;
while (count <= 2)
{
if(search==frame[count])
{
flag = 1;
}
count = count + 1;
}
if(flag==0)
{
miss = miss + 1;
frame[index] = search;
index = (index + 1)%3;
}
}
for (k = 0; k <= 2; k++)
{
cout << frame[k] << endl;
}
cout << miss;
return 0;
}