76 std::shared_ptr<Process> nextTask =
discipline->selectNextTask(readyQueue,
95 if (nextTask !=
nullptr)
97 readyQueue->
remove(nextTask);
144 bool wait = runningTask->advanceBurst();
145 std::shared_ptr<Event> e;
148 e = std::make_shared<Waiting>(newTime);
152 e = std::make_shared<Terminates>(newTime);
154 e->setTask(runningTask);
170 runningTask->updateCurrentAow(newAow);
172 readyQueue->
add(runningTask);
194 log << Utils::Log::Color::lightBlue;
195 log <<
" Scheduler invoked. Ready queue contains ";
203 if (runningTask !=
nullptr)
205 log << Utils::Log::Color::blue;
206 log <<
" Currently running process number "<<runningTask->getPid();
208 if (runningTask->isRealTime())
209 log <<
":"<< runningTask->getJobNumber();
211 log << Utils::Log::Color::normal <<
"\n";
215 log << Utils::Log::Color::blue;
216 log <<
" Processor sleeping" << Utils::Log::Color::normal <<
"\n";
230 log << Utils::Log::Color::green <<
"Using scheduling discipline ";
231 log <<
discipline->getName() << Utils::Log::Color::normal <<
"\n";
void printReports(std::string folder)
double getFreq() const
get the current frequency of the processor
TaskScheduler(std::shared_ptr< SchedulerConfiguration > conf)
void putRunningTaskBackToReadyQueue(std::shared_ptr< Process > task)
This class implements the ready queue and the wait queue. Those queues contain processes ready to run...
void print() const
print a summary of the queue's content
void end(std::string reportsFolder)
cleanup and print reports
void printToFile(std::string folder) const
std::shared_ptr< Event > burstEnd
void printRunningProcess(std::shared_ptr< Process > runningTask)
void setBurstEnd(std::shared_ptr< Event > e)
void remove(std::shared_ptr< Event > e)
remove an element from the list.
static System * getInstance()
void setDiscipline(std::unique_ptr< SchedulingDiscipline > discipline)
void setRunning(std::shared_ptr< Process > p)
unsigned int deadlineMisses
std::string getDisplay() const
get the queue's content as a string, for command-line output
static Queue * getReadyQueue()
get a pointer to the system's ready queue
static Queue * getWaitQueue()
get a pointer to the system's wait queue
void scheduleTask(TriggeringEvent trigger)
This function is the scheduler. When called, it schedule the task to be executed on the processor ama...
void add(double time, double element)
std::shared_ptr< Process > runningTask
std::shared_ptr< SchedulerConfiguration > conf
bool isBusy() const
return true if the processor is running any task
std::shared_ptr< Process > remove(std::shared_ptr< Process > p)
removes the process from the queue. Note: this does not delete the process. Just remove it from queue...
void clearRunningTask(std::shared_ptr< Process > p)
void scheduleEndOfBurst(std::shared_ptr< Process > runningTask)
std::shared_ptr< Event > insert(std::shared_ptr< Event > e)
void incrementJobsArrivalCount()
increments the number of jobs issued since the beginning of simulation
void dealWithMissedDeadlines(std::shared_ptr< Process > p)
to be called when a deadline mis event happends. This function will terminate the task and update the...
std::shared_ptr< Event > getBurstEnd()
bool powered() const
return true if the processor is powered on
Processor * getProc()
return the processor
static SpecialMailbox * getInstance()
Utils::Record deadlinesHistory
void add(std::shared_ptr< Process > p)
add a process to the queue
std::unique_ptr< SchedulingDiscipline > discipline
std::shared_ptr< Process > getRunningTask()
static EventList * getInstance()
Singleton pattern.
bool isRunning(std::shared_ptr< Process > p) const
returns true if the processor is running the task provided as argument
void printDeadlineMissesReport(std::string folder)