diff options
| author | Matthijs Bijman <matthijs@bijman.org> | 2017-02-27 15:19:15 +0100 |
|---|---|---|
| committer | Matthijs Bijman <matthijs@bijman.org> | 2017-02-27 15:19:15 +0100 |
| commit | 34aaaad34e72c921ea72d7b023e5a5270e76dd40 (patch) | |
| tree | 64c65d557c5323a23f4ce6f31b20da744d44badb /Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h | |
| parent | cc5c5a7eac0ebcf97c283e1e0dd1674c855a261a (diff) | |
Add tasks that run on 1 machine
Diffstat (limited to 'Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h')
| -rw-r--r-- | Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h b/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h index 51673fb5..a152c39b 100644 --- a/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h +++ b/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h @@ -20,6 +20,10 @@ namespace Simulation if (workloads.size() == 0) return; + std::remove_if(workloads.begin(), workloads.end(), [](Workload* workload) { + return !workload->dependencyFinished; + }); + for (auto workload : workloads) { workload->setCoresUsed(0); @@ -34,18 +38,26 @@ namespace Simulation ); int taskIndex = 0; - 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(); + if (!workloads.at(taskIndex)->isParallelizable()) + { + workloads.erase(workloads.begin() + taskIndex); + if (workloads.size() == 0) + break; + + taskIndex %= workloads.size(); + } + else + { + taskIndex = (++taskIndex) % workloads.size(); + } } } }; |
