From f16ad7f4cf4471edc4be46a6a3fb8799624fec73 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 24 Oct 2017 16:50:48 +0200 Subject: bug(#4): Prevent scheduling to machines without processing units This change prevents the currently available scheduler implementations from scheduling tasks to machines without processing units, since these machines cannot perform any work. Closes #4 --- .../main/kotlin/nl/atlarge/opendc/platform/scheduler/FifoScheduler.kt | 1 + .../main/kotlin/nl/atlarge/opendc/platform/scheduler/SrtfScheduler.kt | 1 + 2 files changed, 2 insertions(+) (limited to 'opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/platform') diff --git a/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/platform/scheduler/FifoScheduler.kt b/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/platform/scheduler/FifoScheduler.kt index c45ed5e6..6f5db211 100644 --- a/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/platform/scheduler/FifoScheduler.kt +++ b/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/platform/scheduler/FifoScheduler.kt @@ -65,6 +65,7 @@ class FifoScheduler : Scheduler { val iterator = queue.iterator() machines + .filter { it.state.status != Machine.Status.HALT } .forEach { machine -> while (iterator.hasNext()) { val task = iterator.next() diff --git a/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/platform/scheduler/SrtfScheduler.kt b/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/platform/scheduler/SrtfScheduler.kt index 03f37b50..1fbf8c04 100644 --- a/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/platform/scheduler/SrtfScheduler.kt +++ b/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/platform/scheduler/SrtfScheduler.kt @@ -62,6 +62,7 @@ class SrtfScheduler : Scheduler { val iterator = tasks.sortedBy { it.remaining }.iterator() machines + .filter { it.state.status != Machine.Status.HALT } .forEach { machine -> while (iterator.hasNext()) { val task = iterator.next() -- cgit v1.2.3