diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2017-10-24 16:50:48 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2017-10-24 18:09:14 +0200 |
| commit | f16ad7f4cf4471edc4be46a6a3fb8799624fec73 (patch) | |
| tree | 3a27fe7b79b5d25eebea4dfbaf18ef44a82bec4b /opendc-stdlib | |
| parent | 8b53d07898841b328897c60427e6df9f8c71546e (diff) | |
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
Diffstat (limited to 'opendc-stdlib')
4 files changed, 8 insertions, 1 deletions
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() diff --git a/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/container/Datacenter.kt b/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/container/Datacenter.kt index b3d67568..f7eb29d8 100644 --- a/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/container/Datacenter.kt +++ b/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/container/Datacenter.kt @@ -30,7 +30,6 @@ import nl.atlarge.opendc.kernel.Context import nl.atlarge.opendc.kernel.Process import nl.atlarge.opendc.kernel.time.Duration import nl.atlarge.opendc.platform.scheduler.Scheduler -import nl.atlarge.opendc.platform.workload.Job import nl.atlarge.opendc.platform.workload.Task import nl.atlarge.opendc.topology.Entity import nl.atlarge.opendc.topology.machine.Machine diff --git a/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt b/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt index 761f14b1..b5016adb 100644 --- a/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt +++ b/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt @@ -81,6 +81,12 @@ open class Machine : Entity<Machine.State>, Process<Machine> { val cpus = outgoingEdges.destinations<Cpu>("cpu") val speed = cpus.fold(0, { acc, cpu -> acc + cpu.clockRate * cpu.cores }) + // Halt the machine if it has not processing units (see bug #4) + if (cpus.isEmpty()) { + update(State(Status.HALT)) + return + } + var task: Task = receiveTask() update(State(Status.RUNNING, task, load = 1.0, memory = state.memory + 50, temperature = 30.0)) |
