forked from SWE501-Spring2017-Bogazici/FinalProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulation.h
More file actions
75 lines (51 loc) · 1.31 KB
/
Simulation.h
File metadata and controls
75 lines (51 loc) · 1.31 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
/*
* Simulation.h
*
* Created on: Jun 2, 2017
* Author: Can Candan
*/
#ifndef SIMULATION_H_
#define SIMULATION_H_
#include <vector>
#include <queue>
#include "Cpu.h"
#include "OutputDevice.h"
#include "Task.h"
#include "SJFComparator.h"
#include "RRComparator.h"
#include "Event.h"
#include "EventComparator.h"
class Event;
using namespace std;
class Simulation {
private:
vector<Cpu*> cpus;
vector<OutputDevice*> outputDevices;
priority_queue<Event*, vector<Event*>, EventComparator > futureEventsList;
priority_queue<Task*, vector<Task*> , SJFComparator> sjfQueue;
priority_queue<Task*, vector<Task*>, RRComparator> rrQueue;
int taskCounter;
vector<Task*> tasks;
public:
int sjf_queue_max_size;
int rr_queue_max_size;
int max_active_cpu_id;
int max_active_out_id;
double average_wait_time;
double longest_wait_time;
double average_time_spent;
Simulation();
void addTask(Task* task);
void addCpu(Cpu* cpu);
void addOutputDevice(OutputDevice* out);
Cpu* getFirstIdleCpu();
OutputDevice* getFirstIdleOut();
void schedule(Event* event);
void run();
void addToRRQueue(Task* task);
Task* popFromRRQueue();
void addToSJFQueue(Task* task);
Task* popFromSJFQueue();
virtual ~Simulation();
};
#endif /* SIMULATION_H_ */