Scheduler
timeoutEvent.cpp
Go to the documentation of this file.
1 
11 #include "timeoutEvent.h"
12 
13 #include "eventList.h"
14 #include "eventType.h"
15 #include <scheduler/process.h>
16 #include <scheduler/processor.h>
17 #include <scheduler/queue.h>
18 #include <scheduler/system.h>
20 
21 
22 using namespace Scheduler;
23 
25 {
26  std::shared_ptr<TimeOut> nextTimeout = getNextTimeout();
27  if (renew)
28  {
29  nextTimeout->setInterval(interval);
30  EventList::getInstance()->insert(nextTimeout);
31  }
32  print();
33  doWork();
34  return;
35 }
37 {
39 }
40 
41 
42 std::string SchedTimeOut::getName()
43 {
44  return "Timeout";
45 }
46 
47 std::shared_ptr<TimeOut> SchedTimeOut::getNextTimeout()
48 {
49  return std::make_shared<SchedTimeOut>(time+interval);
50 }
51 
53 {
54  return interval;
55 }
56 
57 void TimeOut::setInterval(double inter)
58 {
59  interval = inter;
60 }
61 
63 {
65 }
66 
67 std::shared_ptr<TimeOut> UsageUpdate::getNextTimeout()
68 {
69  return std::make_shared<UsageUpdate>(time + interval);
70 }
71 
72 std::string UsageUpdate::getName()
73 {
74  return "Usage update";
75 }
76 
77 std::string StatsTick::getName()
78 {
79  return "Stats tick";
80 }
81 
82 std::shared_ptr<TimeOut> StatsTick::getNextTimeout()
83 {
84  return std::make_shared<StatsTick>(time + interval);
85 }
86 
88 {
90 }
91 
93 {
95  return;
96 }
97 
98 std::shared_ptr<TimeOut> FreqUpdate::getNextTimeout()
99 {
100  return std::make_shared<FreqUpdate>(time+interval);
101 }
102 
103 std::string FreqUpdate::getName()
104 {
105  return "Frequency update";
106 }
107 
108 
110 {
111 }
112 
113 std::shared_ptr<TimeOut> DummyEvent::getNextTimeout()
114 {
115  return std::make_shared<DummyEvent>(time+interval);
116 }
117 
118 std::string DummyEvent::getName()
119 {
120  return "Dummy event";
121 }
void doWork() override
void doWork() override
virtual void print()
print information about the event
Definition: event.cpp:41
std::shared_ptr< TimeOut > getNextTimeout() override
void doWork() override
std::string getName()
get the name of the event
std::string getName()
get the name of the event
std::shared_ptr< TimeOut > getNextTimeout()
static System * getInstance()
Definition: system.cpp:28
std::shared_ptr< TimeOut > getNextTimeout() override
void updateUsage()
updates the value of the usage percentage.
Definition: processor.cpp:49
std::string getName() override
get the name of the event
std::shared_ptr< TimeOut > getNextTimeout() override
void scheduleTask(TriggeringEvent trigger)
This function is the scheduler. When called, it schedule the task to be executed on the processor ama...
std::shared_ptr< TimeOut > getNextTimeout() override
TaskScheduler * getScheduler()
returns the task scheduler object
Definition: system.cpp:110
void setInterval(double inter)
std::shared_ptr< Event > insert(std::shared_ptr< Event > e)
Definition: eventList.cpp:56
virtual void doWork()
std::string getName() override
get the name of the event
virtual std::shared_ptr< TimeOut > getNextTimeout()=0
void process() override
handle the the event TODO: &#39;process&#39; is maybe not the best word for that, given that our simulator ac...
bool renew
Definition: event.h:59
Processor * getProc()
return the processor
Definition: system.cpp:76
TriggeringEvent eventType
The event type is need by the scheduling discipline, to determine if this kind of event triggers invo...
Definition: event.h:64
std::string getName() override
get the name of the event
void doWork() override
static EventList * getInstance()
Singleton pattern.
Definition: eventList.cpp:22
double time
Definition: event.h:58
void updateFreq()
invokes the frequency governor to changes the frequency of the processor
Definition: system.cpp:102