-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLRUPage.cpp
66 lines (58 loc) · 1.51 KB
/
LRUPage.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
65
66
#include <cstdio>
#include <ctime>
#include "Page.cpp"
using namespace std;
/** @author Robert Howerton
@date 12/01/2014
* Implementation of a virtual memory page for the Least Recently Used algorithm (LRU).
* This class extends the Page class.
*
* -- marked : boolean value to store whether a page has been recently accessed
* -- func isMarked() : Check whether the page is marked.
* -- func mark() : Function to mark a page as just accessed.
* -- func unmark() : Set the marked attribute for the memory page to false.
* -- func setAge() : Set the age of the page. Used when the page is accessed.
* -- func getAge() : Returns the age of the page. Used when determining oldest page of the array.
*/
class LRUPage : public Page{
private:
bool marked;
long age;
public:
/** Constructs new page; marked true by default
@param none
@return new LRU page*/
LRUPage(){
marked = true;
}
/** Checks whether page is marked or not
@param no parameters
@return boolean whether marked or not*/
bool isMarked(void){
return marked;
}
/** Marks page
@param no parameters
@return no return*/
void mark(void){
marked=true;
}
/** Unmarks page
@param no parameters
@return no return*/
void unmark(void){
marked=false;
}
/** Sets new age
@param void
@return no return*/
void access(void){
age = std::clock();
marked = true;
};
/** gets age of the page
@param no parameters
@return returns age*/
long getAge(){return age;
};
};