25 std::atomic<bool> NewJob::startEventScheduling(
false);
26 NewJob *NewJob::processBeingCreated(
nullptr);
30 initEventSchedulingThread();
33 void NewJob::initEventSchedulingThread()
36 startEventScheduling =
false;
37 static std::thread nextEventSchedulingThread(eventSchedulingThreadFunction);
38 processBeingCreated =
nullptr;
39 nextEventSchedulingThread.detach();
43 void NewJob::eventSchedulingThreadFunction()
47 while(!startEventScheduling)
49 processBeingCreated->scheduleNextEvent();
50 startEventScheduling =
false;
57 assert(
task !=
nullptr);
61 task->setDeadlineTimeFromStartTime(
time);
62 processBeingCreated =
this;
66 processBeingCreated->scheduleNextEvent();
78 std::shared_ptr<Process> NewJob::createTask()
80 double deadline = 30.0;
87 void NewJob::scheduleNextEvent()
92 std::shared_ptr<NewJob> e = std::make_shared<NewJob>(
time +
task->getPeriod(),
true);
94 assert(newTask !=
nullptr);
100 scheduleMissedDeadlineEvent();
103 void NewJob::scheduleMissedDeadlineEvent()
105 std::shared_ptr<MissedDeadline> d = std::make_shared<MissedDeadline>(
task->getDeadlineTime());
std::string getName() override
get the name of the event
std::shared_ptr< Process > task
virtual void print()
print information about the event
void queueProcess(std::shared_ptr< Process > p)
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
static System * getInstance()
static int getNewPid()
returns new process identifier. The value returned gets incremented at each call
void scheduleTask(TriggeringEvent trigger)
This function is the scheduler. When called, it schedule the task to be executed on the processor ama...
void process() override
handle the the event TODO: 'process' is maybe not the best word for that, given that our simulator ac...
TaskScheduler * getScheduler()
returns the task scheduler object
std::shared_ptr< Event > insert(std::shared_ptr< Event > e)
static std::shared_ptr< Process > createNextJob(const Process &task)
create the next job for a task
TriggeringEvent eventType
The event type is need by the scheduling discipline, to determine if this kind of event triggers invo...
static EventList * getInstance()
Singleton pattern.