-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLfuSimulation.h
More file actions
39 lines (26 loc) · 919 Bytes
/
LfuSimulation.h
File metadata and controls
39 lines (26 loc) · 919 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
//
// Created by Nick Chapman on 4/19/17.
//
#ifndef PAGING_LFUSIMULATION_H
#define PAGING_LFUSIMULATION_H
#include <queue>
#include "PagingSimulation.h"
using Pair = std::pair<unsigned int, PageTableEntry*>;
class LfuSimulation : public PagingSimulation {
static struct _FrequencyComparator {
bool operator()(std::pair<unsigned int, PageTableEntry*>* const& lhs,
std::pair<unsigned int, PageTableEntry*>* const& rhs) {
return lhs->first > rhs->first;
}
} FrequencyComparator;
std::vector<Pair*> mFrequencyQueue;
std::unordered_map<unsigned int, Pair*> mIteratorMap;
public:
LfuSimulation();
LfuSimulation(unsigned int nFrames, bool verbose);
void UpdateEntry(PageTableEntry* entry);
PageTableEntry* RemoveFrameEntry();
void AddFrameEntry(PageTableEntry* entry);
void Process();
};
#endif //PAGING_LFUSIMULATION_H