-
Notifications
You must be signed in to change notification settings - Fork 0
/
ref.js
44 lines (41 loc) · 1.14 KB
/
ref.js
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
const ref = () => {
let pageTable = new Array(); //frame
let frame = input_frame.value;
let pageList = input_pageList.value;
let cnt_pageFault = (cnt_pageHit = 0);
let unfound, empty;
if (divAll) clear();
for (let i = 0; i < pageList.length; i++) {
unfound = included(i, pageTable, pageList);
if (unfound === true) {
let tmp = {
value: pageList[i],
cue: 0,
};
for (j = 0; j < frame; j++) {
//j가 비어잇을 때 j에 값 넣기
if (!pageTable[j]) {
empty = true;
pageTable.splice(j, 0, tmp);
graph(pageTable, "#f7a260");
break;
}
empty = false;
}
if (j == frame && empty === false) {
let minIndex = getMin(pageTable);
pageTable.splice(minIndex, 1);
pageTable.splice(minIndex, 0, tmp);
graph(pageTable, "#f7a260");
}
cnt_pageFault++;
} else {
ref_notIncluded(i, pageTable, pageList);
cnt_pageHit++;
graph(pageTable, "#a691e6");
}
}
console.log("hit : " + cnt_pageHit);
console.log("Falut : " + cnt_pageFault);
chart(cnt_pageHit, cnt_pageFault);
};