-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPageReplacement.h
25 lines (20 loc) · 953 Bytes
/
PageReplacement.h
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
/*
* The PageReplacement class is an abstract base class representing a page replacement algorithm.
* It maintains a queue of pages with a specified capacity and keeps track of page faults.
*/
#ifndef PAGEREPLACEMENTALGORITHM_H
#define PAGEREPLACEMENTALGORITHM_H
#include <queue>
#include <unordered_set>
class PageReplacement {
protected:
int capacity; // Capacity of the page replacement algorithm
std::queue<int> pages; // Queue to store the pages
std::unordered_set<int> pageSet; // Set to keep track of the pages in the queue
int pageFaults; // Number of page faults
public:
PageReplacement(int capacity);
virtual void accessPage(int pageNum) = 0; // Virtual function to access a page
int getPageFaults() const; // Getter function to retrieve the number of page faults
};
#endif