summaryrefslogtreecommitdiff
path: root/opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt')
-rw-r--r--opendc-stdlib/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt6
1 files changed, 6 insertions, 0 deletions
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))