-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainmemory.h
70 lines (56 loc) · 1.74 KB
/
mainmemory.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
#ifndef MAIN_MEMORY_H
#define MAIN_MEMORY_H
#define VALID 1
#define INVALID 0
#include "processes.h"
#include "cache.h"
#include "pagetable.h"
extern int frame_table_index;
typedef struct frame_table_entry
{
unsigned int frame_number:16; //TODO: will be removed, frame table indexed by frame number.
unsigned int pid:16;
unsigned int page_number:23;
unsigned int valid_bit:1;
unsigned int modified_bit:1;
} frame_table_entry;
typedef struct frame_table
{
frame_table_entry* entry_table[63488];
} frame_table;
//typedef struct data_byte
//{
// unsigned int data:8;
//} data_byte;
typedef struct main_memory_block
{
data_byte entry[512];
} main_memory_block;
typedef struct main_memory
{
frame_table f_table;
// page_table* global_pages[1024];
page_table* p_tables[1024]; //CHANGED from 65536 to 1024//
main_memory_block* blocks[63488]; //65536 - 2048. 1024 each for page table and frame table//
unsigned int total_access_count;
unsigned int access_hit_count;
} main_memory;
typedef struct second_chance_node second_chance_node;
struct second_chance_node
{
unsigned int block_number:16; //Physical block address
main_memory_block* data;
second_chance_node* prev;
second_chance_node* next;
unsigned int second_chance_bit:1;
};
typedef struct second_chance_fifo_queue
{
second_chance_node* head;
second_chance_node* tail;
} second_chance_fifo_queue;
extern second_chance_fifo_queue* second_chance_fifo;
main_memory* main_memory_init();
data_byte* get_l2_block(unsigned int block_number/* physical address/64 */, Proc_Access_Info* temp_pai); //called from l2 cache//;
void main_memory_free(main_memory* mm);
#endif