diff options
Diffstat (limited to 'simulator/opendc-simulator')
2 files changed, 10 insertions, 6 deletions
diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimHypervisor.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimHypervisor.kt index 7c2cfbe3..55eda70f 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimHypervisor.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimHypervisor.kt @@ -103,14 +103,15 @@ public class SimHypervisor( * Run the scheduling process of the hypervisor. */ override suspend fun run(ctx: SimExecutionContext) { - val maxUsage = ctx.machine.cpus.sumByDouble { it.frequency } - val pCPUs = ctx.machine.cpus.indices.sortedBy { ctx.machine.cpus[it].frequency } + val model = ctx.machine + val maxUsage = model.cpus.sumByDouble { it.frequency } + val pCPUs = model.cpus.indices.sortedBy { model.cpus[it].frequency } val vms = mutableSetOf<VmSession>() val vcpus = mutableListOf<VCpu>() - val usage = DoubleArray(ctx.machine.cpus.size) - val burst = LongArray(ctx.machine.cpus.size) + val usage = DoubleArray(model.cpus.size) + val burst = LongArray(model.cpus.size) fun process(command: SchedulerCommand) { when (command) { @@ -180,13 +181,16 @@ public class SimHypervisor( duration = min(duration, req.burst / grantedUsage) } + // XXX We set the minimum duration to 5 minutes here to prevent the rounding issues that are occurring with the FLOPs. + duration = 300.0 + val totalAllocatedUsage = maxUsage - availableUsage var totalAllocatedBurst = 0L availableUsage = totalAllocatedUsage // Divide the requests over the available capacity of the pCPUs fairly for (i in pCPUs) { - val maxCpuUsage = ctx.machine.cpus[i].frequency + val maxCpuUsage = model.cpus[i].frequency val fraction = maxCpuUsage / maxUsage val grantedUsage = min(maxCpuUsage, totalAllocatedUsage * fraction) val grantedBurst = ceil(duration * grantedUsage).toLong() diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt index e7eaa8bf..7b1ddf32 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt @@ -29,7 +29,7 @@ import kotlin.math.min * A [SimWorkload] that replays a workload trace consisting of multiple fragments, each indicating the resource * consumption for some period of time. */ -public class SimTraceWorkload(private val trace: Sequence<Fragment>) : SimWorkload { +public class SimTraceWorkload(public val trace: Sequence<Fragment>) : SimWorkload { override suspend fun run(ctx: SimExecutionContext) { var offset = ctx.clock.millis() |
