-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
37 lines (26 loc) · 1.38 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
// This part of the code is written as an example to show the output of the code.
// According to your needs, you can change or delete this part.
#include <iostream>
#include "MFU_PageReplacement.h"
int main() {
int capacity;
// Getting the maximum number of pages that can be held in memory
std::cout << "***********************************************************************************" << std::endl;
std::cout << " *** Enter the maximum number of pages that can be held in memory: ";
std::cin >> capacity;
// Creating an instance of LRU_PageReplacement
MFU_PageReplacement MFU(capacity);
int pageNum;
std::cout << "***********************************************************************************" << std::endl;
std::cout << " *** Enter the page numbers (enter -1 to terminate): ";
while (std::cin >> pageNum && pageNum != -1) {
// Accessing the page using the MFU algorithm
MFU.accessPage(pageNum);
}
// Displaying the total number of page faults
std::cout << "***********************************************************************************" << std::endl;
std::cout << "\n ---> Total Page Faults: " << MFU.getPageFaults() << std::endl;
std::cout << "***********************************************************************************" << std::endl;
return 0;
}
// An example of how to use the program is shown.