From 702b739a53115f14c402dc24ec30468ef47db2d8 Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Fri, 21 Mar 2025 16:46:40 +0100 Subject: Fixed a small bug that made idle host consume no energy at the start (#322) --- .../src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'opendc-simulator/opendc-simulator-compute/src') diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java index fadfc4d6..1a56650e 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java @@ -44,7 +44,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer private double currentCpuUtilization = 0.0f; private double currentCpuSupplied = 0.0f; // cpu capacity supplied to the mux - private double currentPowerDemand = 0.0f; // power demanded of the psu + private double currentPowerDemand; // power demanded of the psu private double currentPowerSupplied = 0.0f; // cpu capacity supplied by the psu private double maxCapacity; @@ -109,12 +109,13 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer this.cpuModel = cpuModel; this.maxCapacity = this.cpuModel.getTotalCapacity(); - // TODO: connect this to the front-end this.cpuPowerModel = powerModel; this.lastCounterUpdate = clock.millis(); this.cpuFrequencyInv = 1 / this.maxCapacity; + + this.currentPowerDemand = this.cpuPowerModel.computePower(this.currentCpuUtilization); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3