25 int highestPriority = std::numeric_limits<int>::min();
26 std::shared_ptr<Process> candidate = running;
27 if (running !=
nullptr)
28 highestPriority = candidate->getPriority();
29 for (
auto it = readyQueue->
begin() ; it != readyQueue->
end(); it++)
31 if ((*it)->getPriority() > highestPriority)
34 highestPriority = candidate->getPriority();
48 std::vector<std::shared_ptr<Process> > ranking(readyQueue->
size());
50 for (
auto it = readyQueue->
begin(); it != readyQueue->
end(); it++, i++)
54 if (running !=
nullptr)
55 ranking.push_back(running);
57 for (
unsigned int i = 0; i < ranking.size(); i++)
58 ranking[i]->setPriority(ranking.size()-
i);
64 return [](std::shared_ptr<Process> a, std::shared_ptr<Process> b){
return a->getPriority() > b->getPriority();};
This class implements the ready queue and the wait queue. Those queues contain processes ready to run...
std::shared_ptr< Process > selectNextTask(Queue *readyQueue, std::shared_ptr< Process > running, unsigned int)
select the best task to run at this point.
virtual ComparatorPointer getComparator()
return a function pointer to a function that provides comparison of tasks' priorities ...
virtual void updatePriorities(Queue *readyQueue, std::shared_ptr< Process > running)
sets the correct priorities to the tasks, especially if dynamic priorities are used.
virtual bool preempts(TriggeringEvent trigger)
returns true if the argument is a scheduling trigger for this specific discipline ...
bool(* ComparatorPointer)(std::shared_ptr< Process >, std::shared_ptr< Process >)