-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTests.h
More file actions
185 lines (163 loc) · 3.92 KB
/
Tests.h
File metadata and controls
185 lines (163 loc) · 3.92 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#ifndef _TEST_H_
#define _TEST_H_
#include <Windows.h>
#include <string>
class ConcurentIO {
public:
ConcurentIO(HANDLE);
~ConcurentIO();
void write(std::string&);
private:
HANDLE semHandle;
};
#include "MemoryModule.h"
#include "Thread.h"
#include "Semaphore.h"
#include "BoundedBuffer.h"
#include "Monitor.h"
#include "MemoryManagment.h"
class ModuleSimulator : public MemoryInterface {
public:
ModuleSimulator(int);
int read(unsigned long, char*) override;
int write(unsigned long, const char*) override;
int getNumOfCluster() const;
~ModuleSimulator();
private:
char **memory;
int capacity;
CRITICAL_SECTION criticalSection;
};
class LRUSimulator : public SwapAlgorithm {
public:
LRUSimulator(int);
void update(int) override;
int getSwapEntry() override;
~LRUSimulator();
private:
int *entries;
int capacity;
};
class MyThread : public Thread {
public:
MyThread(Semaphore*, int);
void run() override;
private:
Semaphore *ioSem;
int id;
};
class Reader : public Thread {
public:
Reader(Semaphore *_ioSem, ReadersWritersMonitor *_rwm, int _num) : ioSem(_ioSem), rwm(_rwm), numOfIterations(_num) {
}
void run() override;
private:
Semaphore *ioSem;
ReadersWritersMonitor *rwm;
int numOfIterations;
};
class Writer : public Thread {
public:
Writer(Semaphore*, ReadersWritersMonitor*, int);
void run() override;
private:
Semaphore *ioSem;
ReadersWritersMonitor *rwm;
int numOfIterations;
};
typedef BoundedBuffer<int> IntBuffer;
class Producer : public Thread {
public:
Producer(Semaphore*, int, IntBuffer*);
void run() override;
private:
static int pos_id;
int id = pos_id++;
Semaphore *ioSem;
int numOfProfucts;
IntBuffer *myBuffer;
};
class Consumer : public Thread {
public:
Consumer(Semaphore*, int, IntBuffer*);
void run() override;
private:
static int pos_id;
int id = pos_id++;
Semaphore *ioSem;
int numOfProducts;
IntBuffer *myBuffer;
};
class MyHandler : public RequestHandler {
public:
MyHandler();
~MyHandler();
protected:
void handleRequest() override;
private:
int requests;
};
class PartitionThread : public Thread {
public:
PartitionThread(unsigned long, unsigned long, MemoryInterface*);
virtual ~PartitionThread();
protected:
virtual void operation(MemoryInterface*,unsigned long, char*) = 0;
void run() override;
private:
unsigned long startBlock, numOfBlocks;
MemoryInterface *memoryModule;
};
class PartitionReader : public PartitionThread {
public:
PartitionReader(unsigned long, unsigned long, MemoryInterface*);
~PartitionReader();
protected:
void operation(MemoryInterface*,unsigned long, char*) override;
};
class PartitionWriter : public PartitionThread {
public:
PartitionWriter(unsigned long, unsigned long, MemoryInterface*);
~PartitionWriter();
protected:
void operation(MemoryInterface*, unsigned long, char*) override;
};
class BufferedWriterThread : public Thread {
public:
BufferedWriterThread(int, int, MemoryInterface*);
~BufferedWriterThread();
protected:
void run() override;
private:
MemoryInterface *memoryModule;
int numOfOperations, lineSize;
};
class KernelFileThread : public Thread {
public:
KernelFileThread(MemoryInterface*, MemoryManagmentUnit*, int);
~KernelFileThread();
protected:
void run() override;
private:
MemoryInterface *memoryModule;
MemoryManagmentUnit *partitionMemoryManagment;
int numOfDataClusters;
};
namespace tests {
int lruTest();
int BlockCacheMemoryTest();
int ByteCacheMemoryTest();
int ThreadAndSemaphoreTest();
int MonitorTest();
int BoundedBufferTest();
int SingleThreadSafeLRUTest();
int RequestsHandlerTest();
int PartitionCacheCompareAndTest();
int BufferedWriterTest();
int QueueTest();
int KernelFileTest();
int MultiThreadKernelFileTest();//includes partition memory managment test
int BitVectorTest();
int BasicPartitionFunctionTest();
}
#endif