summaryrefslogtreecommitdiff
path: root/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h
diff options
context:
space:
mode:
Diffstat (limited to 'Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h')
-rw-r--r--Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h30
1 files changed, 18 insertions, 12 deletions
diff --git a/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h b/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h
index 15265985..51673fb5 100644
--- a/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h
+++ b/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h
@@ -12,14 +12,19 @@ namespace Simulation
}
public:
- /*
- Distribute workloads according to the srtf principle
+ /**
+ * \brief Distribute workloads according to the srtf principle.
*/
void schedule(std::vector<std::reference_wrapper<Modeling::Machine>>& machines, std::vector<Workload*> workloads) override
{
if (workloads.size() == 0)
return;
+ for (auto workload : workloads)
+ {
+ workload->setCoresUsed(0);
+ }
+
std::sort(
workloads.begin(),
workloads.end(),
@@ -30,17 +35,18 @@ namespace Simulation
int taskIndex = 0;
- std::for_each(
- machines.begin(),
- machines.end(),
- [&workloads, &taskIndex](Modeling::Machine& machine) {
- while (!workloads.at(taskIndex)->dependencyFinished)
- taskIndex = (++taskIndex) % workloads.size();
-
- machine.giveTask(workloads.at(taskIndex));
+ for (auto machine : machines)
+ {
+ while (!workloads.at(taskIndex)->dependencyFinished)
taskIndex = (++taskIndex) % workloads.size();
- }
- );
+
+ machine.get().giveTask(workloads.at(taskIndex));
+ workloads.at(taskIndex)->setCoresUsed(
+ workloads.at(taskIndex)->getCoresUsed() + machine.get().getNumberOfCores()
+ );
+
+ taskIndex = (++taskIndex) % workloads.size();
+ }
}
};
}