-
Notifications
You must be signed in to change notification settings - Fork 2
/
hardware.h
84 lines (68 loc) · 1.33 KB
/
hardware.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef HARDWARE
#define HARDWARE
#include <inttypes.h>
struct Node {
int64_t index;
struct Node *next;
};
struct L2CacheSet {
int64_t tags[8];
int64_t dirty[8];
int64_t valid[8];
struct Node *head;
struct Node *tail;
int64_t listCount;
};
struct L1Cache {
int64_t tags[128];
int64_t valid[128];
};
struct L2Cache {
struct L2CacheSet sets[128];
};
struct VictimCache {
int64_t tags[8];
int64_t lruCounter[8];
int64_t valid[8];
};
struct FrameTable {
int64_t pid[65536];
int64_t initialFrameAlloc;
};
struct PageTable {
int64_t entries[256];
};
struct MainMemory {
int64_t freeFrames;
int64_t nextFreeFrame;
struct PageTable *frames[65536];
int64_t lru[65536];
};
struct TLB {
int64_t pageNumber[32];
int64_t frameNumber[32];
int64_t pid[32];
int64_t valid[32];
int64_t lru[32][32];
};
struct Hardware {
struct L1Cache *l1d;
struct L1Cache *l1i;
struct L2Cache *l2;
struct VictimCache *victim;
struct MainMemory *mainMemory;
struct TLB *tlb;
struct FrameTable *frametable;
};
struct SegmentTable {
int64_t csBase;
int64_t dsBase;
int64_t csLength;
int64_t dsLength;
};
struct Process {
int64_t pid;
struct SegmentTable *ldt;
int64_t state; // Thrashing: 0 -> suspended, 1 -> active
};
#endif