-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymbolic_scheduler.h
70 lines (55 loc) · 1.81 KB
/
symbolic_scheduler.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
58
59
60
61
62
63
64
65
66
67
68
69
70
// -*- C++ -*-
#pragma once
#include <vector>
#include <set>
#include <algorithm>
#include <memory>
#include "sem.h"
#include "job.h"
#include "scheduler.h"
#include "dbl.h"
class SymbolicScheduler
{
private:
std::vector<Job*> jobs;
Scheduler *sched;
std::unique_ptr<Job> jobPart;
JobCmp cmp;
int crit;
Time time;
void setJobPart(std::unique_ptr<Job>);
public:
SymbolicScheduler *sim_list_next;
static Semaphore sem;
static Semaphore psem;
static std::mutex mutex;
static SymbolicScheduler *sim_list;
public:
SymbolicScheduler(Scheduler *_sched, Time _time,
std::vector<Job*> *_jobs = nullptr, int _crit = 0)
:
jobs(_jobs ? *_jobs : _sched->jobs), sched(_sched),
jobPart(nullptr), cmp(sched->jobCmp(_crit)),
crit(_crit), time(_time)
{
// If a jobs vector is passed, it is expected to be sorted.
// Else, jobs is sorted into the order of descending release
// times.
if (!_jobs) {
std::sort(jobs.begin(), jobs.end(),
[](Job const *j1, Job const *j2)
{ return j1->release() > j2->release(); });
}
}
~SymbolicScheduler() = default;
SymbolicScheduler(SymbolicScheduler&&) = default;
static void print_statistic();
void jumpToTime(int t);
Job* nextJob();
int nextSchedEventFor(Job *job);
void removeJob(Job *oldJ);
void updateJob(Job *oldJ, Job *newJ);
void findCritDeadlinesUpto(Time const & t, std::vector<Job*> *_jobs);
void runNextLevel(SymbolicScheduler& sim, int level);
void run(int level);
};