-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoryManagment.h
More file actions
55 lines (47 loc) · 1.46 KB
/
MemoryManagment.h
File metadata and controls
55 lines (47 loc) · 1.46 KB
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
#ifndef _MEMORY_MANAGMENT_H_
#define _MEMORY_MANAGMENT_H_
#include <Windows.h>
#include "MemoryModule.h"
class MemoryManagmentUnit {
public:
virtual unsigned long allocate() = 0;
virtual void free(unsigned long) = 0;
virtual ~MemoryManagmentUnit() = 0;
};
class PartitionMemoryManagmentUnit : public MemoryManagmentUnit {
public:
PartitionMemoryManagmentUnit(unsigned long, MemoryInterface*);
unsigned long allocate() override;
void free(unsigned long) override;
void format();
~PartitionMemoryManagmentUnit();
private:
unsigned long findFreeCluster();
void read(unsigned long);
void flush();
CRITICAL_SECTION criticalSection;
bool isChanged;
unsigned long numOfClustersInPartition;
int numOfClusters, inMemory;
char *bitVectorBuffer;
MemoryInterface *memoryModule;
};
class FileMemoryManagmentUnit : public MemoryManagmentUnit {
public:
FileMemoryManagmentUnit(CacheMemory*, MemoryManagmentUnit*,unsigned long, unsigned long);
unsigned long allocate() override;
void free(unsigned long) override;
unsigned long getIndexCluster() const;
~FileMemoryManagmentUnit();
private:
unsigned long allocateNewIndexCluster();
void freeIndexCluster();
void write(int,int,unsigned long);
unsigned long read(int, int);
MemoryManagmentUnit *partitionMemoryManagmentUnit;
CacheMemory *indexCache;
unsigned long numOfDataClusters, indexCluster;
int numOfIndexClusters;
static const unsigned long MAX_FILE_CLUSTERS;
};
#endif