forked from samehkhamis/RegionPushRelabel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemoryManager.h
57 lines (47 loc) · 1.27 KB
/
MemoryManager.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
/////////////////////////////////////////////////////////////////////////////
// Filename: MemoryManager.h
// Author: Sameh Khamis
//
// Description: Implementation of a paging memory manager for out-of-core
// processing of graphs by the Push-Relabel algorithm
/////////////////////////////////////////////////////////////////////////////
#ifndef _MEMORY_MANAGER
#define _MEMORY_MANAGER
#include <fstream>
#include <sstream>
#include <iomanip>
#include <deque>
using namespace std;
#include <boost/filesystem.hpp>
namespace filesys = boost::filesystem;
#include <boost/iostreams/positioning.hpp>
using namespace boost::iostreams;
class MemoryManager
{
public:
typedef stream_offset int64;
static const int PAGE_NOT_FOUND = -1;
private:
struct ResidentPage
{
char* addr;
int ref_count;
unsigned lru_timestamp;
int page_id;
};
fstream *handle;
string name;
int *page_table;
bool *mapped_before;
int64 page_size;
unsigned timestamp;
deque<ResidentPage> resident;
void map(ResidentPage* page);
void unmap(ResidentPage* page);
public:
MemoryManager(int64 space_size, int64 page_size, int resident_page_count);
~MemoryManager();
void* add_ref(int64 addr);
void remove_ref(int64 addr);
};
#endif