-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim_mem.h
57 lines (46 loc) · 1.12 KB
/
sim_mem.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
#ifndef _EX4
#define _EX4
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <queue>
using namespace std;
#define MEMORY_SIZE 20
typedef struct page_descriptor_t {
unsigned int V; // valid
unsigned int D; // dirty
unsigned int P; // permission
unsigned int frame; //the number of a frame if in case it is page-mapped
}page_descriptor;
void fatal(const char*);
void error(const char*);
class sim_mem {
private:
int swapfile_fd; //swap file fd
int program_fd; //executable file fd
int text_size;
int data_size;
int bss_size;
int heap_stack_size;
int num_of_pages;
int page_size;
int program_size;
page_descriptor *page_table;
queue<int> frames;
queue<int> pages;
int logical_address_maker(int);
public:
sim_mem(char [], char [], int, int, int, int, int, int );
~sim_mem();
char load(int);
void store(int, char);
void print_memory();
void print_swap ();
void print_page_table();
};
extern char main_memory[MEMORY_SIZE];
#endif