diff options
| author | Matthijs Bijman <matthijs@bijman.org> | 2017-02-27 13:55:50 +0100 |
|---|---|---|
| committer | Matthijs Bijman <matthijs@bijman.org> | 2017-02-27 13:55:50 +0100 |
| commit | cc5c5a7eac0ebcf97c283e1e0dd1674c855a261a (patch) | |
| tree | 841f95e14a00cb6d23d4e357c9e0cfcbdc3c9a2a /Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h | |
| parent | 0709a81231b695caecb2269fe23d8dadeb764892 (diff) | |
Implement logging of cores_used in task_states
Diffstat (limited to 'Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h')
| -rw-r--r-- | Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h | 30 |
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(); + } } }; } |
