summaryrefslogtreecommitdiff
path: root/opendc-simulator
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2025-02-17 12:59:39 +0100
committerGitHub <noreply@github.com>2025-02-17 12:59:39 +0100
commite9080b6280a3a1264a35748eccd1c58205c001bf (patch)
tree4e34892281a492e0cc12e50bf4ac0f58a3b83dca /opendc-simulator
parent20d8587552840c0379e35f70dad05c46de439122 (diff)
Fixed bugs (#304)
Diffstat (limited to 'opendc-simulator')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/trace/SimTraceWorkload.java4
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java13
2 files changed, 12 insertions, 5 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/trace/SimTraceWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/trace/SimTraceWorkload.java
index b6d939c9..46354d4c 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/trace/SimTraceWorkload.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/trace/SimTraceWorkload.java
@@ -124,6 +124,10 @@ public class SimTraceWorkload extends SimWorkload implements FlowConsumer {
long remainingDuration = this.scalingPolicy.getRemainingDuration(
this.cpuFreqDemand, this.newCpuFreqSupplied, this.remainingWork);
+ if (remainingDuration == 0.0) {
+ this.remainingWork = 0.0;
+ }
+
return now + remainingDuration;
}
diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java
index ff7ff199..dcbd79bb 100644
--- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java
+++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java
@@ -39,8 +39,7 @@ public class FlowDistributor extends FlowNode implements FlowSupplier, FlowConsu
private double currentIncomingSupply; // The current supply provided by the supplier
private boolean outgoingDemandUpdateNeeded = false;
- private final Set<Integer> updatedDemands =
- new HashSet<>(); // Array of consumers that updated their demand in this cycle
+ private Set<Integer> updatedDemands = new HashSet<>(); // Array of consumers that updated their demand in this cycle
private boolean overloaded = false;
@@ -209,14 +208,18 @@ public class FlowDistributor extends FlowNode implements FlowSupplier, FlowConsu
other.setConsumerIndex(other.getConsumerIndex() - 1);
}
- for (int idx_other : this.updatedDemands) {
+ HashSet newUpdatedDemands = new HashSet<>();
+ for (int idx_other : this.updatedDemands) {
if (idx_other > idx) {
- this.updatedDemands.remove(idx_other);
- this.updatedDemands.add(idx_other - 1);
+ newUpdatedDemands.add(idx_other - 1);
+ } else {
+ newUpdatedDemands.add(idx_other);
}
}
+ this.updatedDemands = newUpdatedDemands;
+
this.outgoingDemandUpdateNeeded = true;
this.invalidate();
}