-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtlb.h
44 lines (31 loc) · 988 Bytes
/
tlb.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef TLB
#define TLB
#include <map>
#include <deque>
#include "math.h"
#define MEMORY_SPACE_SIZE 32
#define MAX_QUEUE_SIZE 10
class tlb
{
public:
// constructor
tlb(int vpnNumBits, int capacity);
// cache mapping of vpn 2 pfn
std::map<unsigned int /*vpn*/, unsigned int /*pfn*/> vpn2pfn;
// queue of most recently accessed pages. Used to determine which mapping to remove from cache
std::deque<unsigned int> recentPagesQueue; // always be size 10
// cache information
int capacity; // capacity of cache
unsigned int vpnMask; // bit mask for masking off cpn
// setter method
void setVpnMask(int vpnNumBits);
// cache methods
bool usingTlb();
bool hasMapping(unsigned int vpn);
void insertMapping(unsigned int vpn, unsigned int frameNum);
// queue methods
void updateQueue(unsigned int recentVpn);
bool queueContains(unsigned int vpn);
void eraseVpnFromQueue(unsigned int vpn);
};
#endif