-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathframeTable.h
74 lines (52 loc) · 2.43 KB
/
frameTable.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
// #include "dataTypes.h"
#define NUM_FRAMES 65536
#define NUM_NON_REPLACABLE_FRAMES 1024
typedef struct
{
int26 pageNum; //Page number
int pid;
int16 LfuCount; //LFU count of the frame
unsigned int lock: 1; //lock bit used when frame is allocated
unsigned int dirtyBit: 1; //dirty bit
unsigned int emptyBit: 1; // Tells whether a frame has been allocated or not | set if allocated
unsigned int considerInLfu: 1; //Bit that indicates whether frame of MM belongs to replaceable of non-replaceable part
int level ; // which level of page table would contain an entry corresponding to pageNum
unsigned int segNum : 4; // segment number to which page belongs
}
frameTableEntry;
typedef struct
{
frameTableEntry entries[NUM_FRAMES]; // Frame Table is array of frameTableEntry
}
FrameTable;
// Returns a replacable frame for allocation or -1 if no frame is available
int getReplacableEmptyFrame();
//Returns an irreplacable frame for allocation or -1 if no frame is available
int getNonReplaceableFrame();
//Returns the LFU frame to use for replacement
int getLfuFrameNum();
//Returns the value of the dirty bit of the given frame number
short unsigned getDirtyBitFrameTable(int index);
//Sets the value of the dirty bit of the given frame number to the value given as input by user
short unsigned setDirtyBitFrameTable(int index, int value);
//Returns the value of the empty bit of the given frame number
short unsigned getEmptyBitFrameTable(int index);
//Sets the value of the empty bit of the given frame number to the value given as input by user
short unsigned setEmptyBitFrameTable(int index, int value);
//Finds an empty frame and allocates it to a process.
//Takes segment number, page table level in which page fault occured and page index in the pafge table as input
int allocateFrame(int pid,int segno,pageTable *pT,int pageNum,int level);
//Writes a dirty frame back to disk and sets its empty bit to zero.
int invalidateFrame(int frameNo);
//Initializes the ADT of the frame table
int initFrameTable();
//Runs the LFU frame ageing alogrithm
int frameAgeing();
//Updates the frame access count which is used in LFU page replacement in the frame table
int updateLfuCount(int frameNo);
//Locks the Frame
int setLock(int frameNo);
//Function to read from memory and update the lfu count
int readFromMemory(int frameNo);
//Function to write to memory, update the lfu count and set dirty bit of the frame
int writeToMemory(int frameNo);