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 --- .../src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt') 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, Process { val cpus = outgoingEdges.destinations("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)) -- cgit v1.2.3