blob: a4be9e6d8191c375f2abdc6c30f11b405539e293 (
plain) (
blame)
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
|
#include "tasks.h"
#include "schedule_sim.h"
Job::Job(const Task &tsk,
unsigned long relt,
unsigned long sequence_no,
unsigned long cst)
: task(tsk), release(relt), allocation(0), seqno(sequence_no)
{
if (!cst)
cost = task.get_wcet();
else
cost = cst;
}
void Job::init_next(simtime_t cost,
simtime_t inter_arrival_time)
{
allocation = 0;
/* if cost == 0, then we keep the last cost */
if (cost != 0)
this->cost = cost;
release += task.get_period() + inter_arrival_time;
seqno++;
}
void PeriodicJobSequence::completed(simtime_t when, int proc)
{
init_next();
get_sim()->add_release(this);
}
void run_periodic_simulation(ScheduleSimulation& sim,
TaskSet& ts,
simtime_t end_of_simulation)
{
PeriodicJobSequence** jobs;
jobs = new PeriodicJobSequence*[ts.get_task_count()];
for (unsigned int i = 0; i < ts.get_task_count(); i++)
{
jobs[i] = new PeriodicJobSequence(ts[i]);
jobs[i]->set_simulation(&sim);
sim.add_release(jobs[i]);
}
sim.simulate_until(end_of_simulation);
for (unsigned int i = 0; i < ts.get_task_count(); i++)
delete jobs[i];
delete [] jobs;
}
|