34 conf = std::make_shared<SchedulerConfiguration>(
"configuration.conf");
51 std::string value = conf->getStringValue(
"taskSet",
"tasksetSource");
52 if (!value.compare(
"xml"))
53 initializeTaskSetFromXml();
54 else if (!value.compare(
"random"))
55 initializeTaskSetRandomly();
56 else if (!value.compare(
"compiled"))
57 initializeTaskSetAtCompileTime();
58 else initializeTaskSetAtCompileTime();
61 void SchedulingSimulator::initializeTaskSetFromXml()
64 std::shared_ptr<std::vector<std::shared_ptr<Process>>>
66 for (
size_t i = 0;
i < taskset->size();
i++)
69 double startTime = 0.1;
70 std::shared_ptr<Event> rt = std::make_shared<NewJob>(startTime);
71 rt->setTask((*taskset)[i]);
78 void SchedulingSimulator::initializeTaskSetRandomly()
80 int nbOfTasks = conf->getIntValue(
"taskSet",
"nbOfTasks");
81 double utilization = conf->getDoubleValue(
"taskSet",
"utilization");
82 time_t tasksetSeed = conf->getIntValue(
"taskSet",
"seed");
83 std::shared_ptr<Utils::BoundedRandomDistribution> dist;
84 dist = conf->getDistributionFromFile(&randomGenerator);
86 tasksetSeed,
true,
true, dist);
89 void SchedulingSimulator::initializeTaskSetAtCompileTime()
133 double period,
double wcet,
double deadline,
int priority,
double bcet,
140 p->setPowerCoeff(powerCoeff);
141 std::shared_ptr<Event> rt = std::make_shared<NewJob>(startTime);
155 randomGenerator.
seed(seed);
163 std::shared_ptr<Event> stopEvent = std::make_shared<StopSimulation>(
time);
164 eventList->
insert(stopEvent);
169 std::shared_ptr<UsageUpdate> cpuUsageUpdate = std::make_shared<UsageUpdate>(start);
170 cpuUsageUpdate->setInterval(interval);
176 std::shared_ptr<StatsTick> tick = std::make_shared<StatsTick>(start);
177 tick->setInterval(interval);
183 std::shared_ptr<FreqUpdate> freqTO = std::make_shared<FreqUpdate>(start);
184 freqTO->setInterval(interval);
190 std::shared_ptr<SchedTimeOut> timeout = std::make_shared<SchedTimeOut>(start);
191 timeout->setInterval(interval);
198 std::shared_ptr<DummyEvent> dummy = std::make_shared<DummyEvent>(start);
199 dummy->setInterval(interval);
213 std::shared_ptr<Event> e = list->
getHead();
216 double timeInterval = e->getTime() - previousTime;
217 previousTime = e->getTime();
222 static double previousTimeTrack = 0.0;
223 double timeTrack = e->getTime();
225 if (timeTrack - previousTimeTrack > 100000.0)
227 std::cerr <<
"time: "<< timeTrack <<
"\n";
228 previousTimeTrack = timeTrack;
231 std::cerr <<
"after the startScheduler\n";
238 std::shared_ptr<StartProc>
startProc = std::make_shared<StartProc>(start);
static void buildSystem(std::shared_ptr< SchedulerConfiguration > conf)
static void updateTime(double t)
std::shared_ptr< Process > createRealTimeTask(double startTime, double period, double wcet, double deadline=0.0, int priority=0, double bcet=0.0, double powerCoeff=1.0)
creates a new real-time task event and add it to the event scheduling queue
void setFreqUpdate(double start, double interval)
Sets a timer at the end of which the frequency governor updates the frequency of processor.
void startScheduler()
call this function to launch the simulation
void updateTemperature(double timeInterval)
updates and logs the temperature of the processor. This function has to be called at least every time...
void addRealTimeTask(std::shared_ptr< Process > p)
add a real-time task to the system's list
std::shared_ptr< std::vector< std::shared_ptr< Process > > > getRealTimeTaskSetFromXml(std::string filename)
static std::shared_ptr< Process > createRealTimeTask(double wcet, double T, double dl, int pid, int priority=0, double bcet=0.0)
creates a real time task
void setRandomGenerator(Utils::RandomGenerator *gen)
set a random generator TODO: shouldn't that be part of the constructor?
static System * getInstance()
static void setRandomGenerator(Utils::RandomGenerator *gen)
specify what random generator to use for interactive task length
std::shared_ptr< Event > getHead()
get the element at the head of the list
static int getNewPid()
returns new process identifier. The value returned gets incremented at each call
std::shared_ptr< Event > pop()
void seedRandomGenerator(time_t seed)
seeds the random generator
std::shared_ptr< Event > insert(std::shared_ptr< Event > e)
static void generate(SchedulingSimulator *simulator, unsigned int nbOfTasks, double utilization, time_t seed, bool critical=true, bool integerPeriod=false, std::shared_ptr< Utils::BoundedRandomDistribution > dist=nullptr)
generates a random task set. The deadline will be equal to the period. The start time will be 0...
void turnOnProcessor(double start)
turns on the processor
void createInteractiveProcess(double startTime)
creates a new interactive process event and adds it to the event scheduling queue ...
void setStatsTick(double start, double interval)
void setDummyEvent(double start, double interval)
void initializeTaskSet()
Builds the task set using a variety of methods This function is an alternative to using createRealTim...
void setSchedulerTimeout(double start, double interval)
sets the timeout at which the task scheduler is invoked
void endSimulation(double time)
set the end of the simulation
void setUsageCalculationTimeout(double start, double interval)
Sets a UsageUpdate timeout.
static void end()
call this function before any other
static EventList * getInstance()
Singleton pattern.