Skip to content

Commit 702b739

Browse files
Fixed a small bug that made idle host consume no energy at the start (#322)
1 parent f16e799 commit 702b739

File tree

1 file changed

+3
-2
lines changed
  • opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu

1 file changed

+3
-2
lines changed

opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer
4444
private double currentCpuUtilization = 0.0f;
4545
private double currentCpuSupplied = 0.0f; // cpu capacity supplied to the mux
4646

47-
private double currentPowerDemand = 0.0f; // power demanded of the psu
47+
private double currentPowerDemand; // power demanded of the psu
4848
private double currentPowerSupplied = 0.0f; // cpu capacity supplied by the psu
4949

5050
private double maxCapacity;
@@ -109,12 +109,13 @@ public SimCpu(FlowEngine engine, CpuModel cpuModel, CpuPowerModel powerModel, in
109109
this.cpuModel = cpuModel;
110110
this.maxCapacity = this.cpuModel.getTotalCapacity();
111111

112-
// TODO: connect this to the front-end
113112
this.cpuPowerModel = powerModel;
114113

115114
this.lastCounterUpdate = clock.millis();
116115

117116
this.cpuFrequencyInv = 1 / this.maxCapacity;
117+
118+
this.currentPowerDemand = this.cpuPowerModel.computePower(this.currentCpuUtilization);
118119
}
119120

120121
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)