Class CPU
java.lang.Object
desmoj.core.simulator.NamedObject
desmoj.core.simulator.ModelComponent
desmoj.core.simulator.Schedulable
desmoj.core.simulator.EventAbstract
desmoj.core.simulator.ExternalEvent
de.rss.fachstudie.MiSim.resources.cpu.CPU
public class CPU
extends desmoj.core.simulator.ExternalEvent
Represents a CPU resource.
The CPU implementation supports multithreading with a thread pool size and multiple scheduling strategies.
- Author:
- Lion Wagner
- See Also:
CPUProcess,CPUProcessScheduler,CPU(Model, String, boolean, MicroserviceInstance, int, CPUProcessScheduler, int)
-
Field Summary
Fields inherited from class desmoj.core.simulator.EventAbstract
numberOfEntitiesFields inherited from class desmoj.core.simulator.Schedulable
_schedule -
Constructor Summary
Constructors Constructor Description CPU(desmoj.core.simulator.Model model, String name, boolean showInTrace, int capacity, int threadPoolSize, MicroserviceInstance owner)Constructs a new CPU with a default Round-Robin scheduler.CPU(desmoj.core.simulator.Model model, String name, boolean showInTrace, int capacity, MicroserviceInstance owner)Constructs a new CPU with a default Round-Robin scheduler and a default thread pool size ofCPUImpl.DEFAULT_THREADPOOLSIZE.CPU(desmoj.core.simulator.Model model, String name, boolean showInTrace, int capacity, CPUProcessScheduler scheduler, MicroserviceInstance owner)Constructs a new CPU with a default thread pool size ofCPUImpl.DEFAULT_THREADPOOLSIZE.CPU(desmoj.core.simulator.Model model, String name, boolean showInTrace, MicroserviceInstance owner, int capacity, CPUProcessScheduler scheduler, int threadPoolSize)Constructs a new CPU resource instance. -
Method Summary
Modifier and Type Method Description voidclear()Forcibly stops all currently running and scheduled processes.voideventRoutine()Generic routine of the CPU implementation.doublegetCurrentRelativeWorkDemand()doublegetCurrentUsage()voidsubmitProcess(CPUProcess process)Schedules the given process to be executed.Methods inherited from class desmoj.core.simulator.ExternalEvent
clone, schedule, schedule, schedule, schedule, scheduleAfter, scheduleBefore, schedulePreemptMethods inherited from class desmoj.core.simulator.EventAbstract
generateTraceForScheduling, getNumberOfEntities, getRealTimeConstraint, getSchedulingPriority, isExternal, setRealTimeConstraint, setSchedulingPriorityMethods inherited from class desmoj.core.simulator.Schedulable
assignReporter, cancel, getCorrespondingReportable, isCurrent, isScheduled, rename, reSchedule, reSchedule, reSchedulePreempt, scheduledNext, setCorrespondingReportableMethods inherited from class desmoj.core.simulator.ModelComponent
current, currentEntity, currentEntityAll, currentEvent, currentlySendDebugNotes, currentlySendTraceNotes, currentModel, currentSimProcess, debugIsOn, debugOff, debugOn, getModel, isExperimentCompatible, isModelCompatible, presentTime, sendDebugNote, sendMessage, sendTraceNote, sendWarning, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOnMethods inherited from class desmoj.core.simulator.NamedObject
getName, getQuotedName, toString
-
Constructor Details
-
CPU
public CPU(desmoj.core.simulator.Model model, String name, boolean showInTrace, int capacity, MicroserviceInstance owner)Constructs a new CPU with a default Round-Robin scheduler and a default thread pool size ofCPUImpl.DEFAULT_THREADPOOLSIZE. -
CPU
public CPU(desmoj.core.simulator.Model model, String name, boolean showInTrace, int capacity, int threadPoolSize, MicroserviceInstance owner)Constructs a new CPU with a default Round-Robin scheduler. -
CPU
public CPU(desmoj.core.simulator.Model model, String name, boolean showInTrace, int capacity, CPUProcessScheduler scheduler, MicroserviceInstance owner)Constructs a new CPU with a default thread pool size ofCPUImpl.DEFAULT_THREADPOOLSIZE. -
CPU
public CPU(desmoj.core.simulator.Model model, String name, boolean showInTrace, MicroserviceInstance owner, int capacity, CPUProcessScheduler scheduler, int threadPoolSize)Constructs a new CPU resource instance.- Parameters:
model- parent and simulation modelname- CPU name, should be formatted {}_{}showInTrace- whether the computation events should be shown in the traceowner- instance that owns this cpucapacity- total capacity of the cpu resource. Each thread will be assigned a capacity ofMath.floor(capacity/threadPoolSize).scheduler- implementation of a scheduling strategy that should be used by the CPUthreadPoolSize- thread count of the CPU- See Also:
CPUProcessScheduler,RoundRobinScheduler
-
-
Method Details
-
submitProcess
Schedules the given process to be executed.Depending on the choice of scheduler (fair/unfair) the execution is not guaranteed.
- Parameters:
process-CPUProcessobject to be submitted for scheduling- See Also:
CPUProcess,CPUProcessScheduler
-
eventRoutine
public void eventRoutine() throws co.paralleluniverse.fibers.SuspendExecutionGeneric routine of the CPU implementation.As long as processes can be scheduled, the cpu retrieves the next process and target burst duration from the scheduler. Based on the retrieved data a
ComputationBurstCompletedEventis scheduled to execute after the target burst duration.ComputationBurstCompletedEvents will notify this object about this object about thier execution via theCPUImpl#onBurstFinishedmethod.- Specified by:
eventRoutinein classdesmoj.core.simulator.ExternalEvent- Throws:
co.paralleluniverse.fibers.SuspendExecution- See Also:
ComputationBurstCompletedEvent
-
getCurrentRelativeWorkDemand
public double getCurrentRelativeWorkDemand()- Returns:
- the remaining amount of cycles to complete the current workload
-
getCurrentUsage
public double getCurrentUsage() -
clear
public void clear()Forcibly stops all currently running and scheduled processes.
-