Package cambio.simulator.resources.cpu
Class CPUProcess
java.lang.Object
cambio.simulator.resources.cpu.CPUProcess
- All Implemented Interfaces:
Comparable<CPUProcess>
Data-class that contains information about a currently running (or potentially finished) process.
More specifically, it concentrates on holding information about the total work units totally needed and left to complete the process. Further, there are methods to manipulate the latter.
For the purpose of compatibility (e.g. non impacting operations) a demand of 0
is allowed.
- Author:
- Lion Wagner
-
Constructor Summary
ConstructorsConstructorDescriptionCPUProcess
(int demandTotal) Constructor that can be used to create artificial load onto the system.CPUProcess
(Request request) Creates aCPUProcess
for the givenRequest
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels the current Burst of this process and reset its progress.int
compareTo
(CPUProcess other) Natural sorting is based on left over demand.int
Gets the remaining demand from before the start of the latest burst.double
getDemandRemainder
(desmoj.core.simulator.TimeInstant peekTime, double computingCapacityPerTimeUnit) Calculates the time/work left for the current burst of this processes at the specific point int time.int
void
reduceDemandRemainder
(double amount) Subtracts the given demand amount from he this process remaining demand.void
setCurrentBurstCompletionEvent
(ComputationBurstCompletedEvent currentBurstCompletionEvent) Sets the event, that should be executed upon the next completion of a burst of this process.void
stampCurrentBurstStarted
(desmoj.core.simulator.TimeInstant start) Stamps the start of the next cpu burst.
-
Constructor Details
-
CPUProcess
public CPUProcess(int demandTotal) Constructor that can be used to create artificial load onto the system.- Parameters:
demandTotal
- load in simulation units
-
CPUProcess
Creates aCPUProcess
for the givenRequest
.- Parameters:
request
-Request
that should be represented by this process.
-
-
Method Details
-
getDemandTotal
public int getDemandTotal() -
getDemandRemainder
public int getDemandRemainder()Gets the remaining demand from before the start of the latest burst.- Returns:
- the remaining demand from before the start of the latest burst.
-
getDemandRemainder
public double getDemandRemainder(desmoj.core.simulator.TimeInstant peekTime, double computingCapacityPerTimeUnit) Calculates the time/work left for the current burst of this processes at the specific point int time.Specifically returns: Remainder at start of Burst - (peekTime - startTime) * computingCapacityPerTimeUnit
- Parameters:
peekTime
- time for which the current remainder should be calculatedcomputingCapacityPerTimeUnit
- computing capacity of a thread per time unit- Returns:
- the remaining demand of the currently handled process
-
getRequest
-
compareTo
Natural sorting is based on left over demand.- Specified by:
compareTo
in interfaceComparable<CPUProcess>
-
reduceDemandRemainder
public void reduceDemandRemainder(double amount) Subtracts the given demand amount from he this process remaining demand.- Parameters:
amount
- value by which the demand remainder should be reduced- Throws:
IllegalArgumentException
- if the given amount is larger than the demand remainder.
-
stampCurrentBurstStarted
public void stampCurrentBurstStarted(desmoj.core.simulator.TimeInstant start) Stamps the start of the next cpu burst.- Parameters:
start
- time when the burst started.
-
cancel
public void cancel()Cancels the current Burst of this process and reset its progress. -
setCurrentBurstCompletionEvent
public void setCurrentBurstCompletionEvent(ComputationBurstCompletedEvent currentBurstCompletionEvent) Sets the event, that should be executed upon the next completion of a burst of this process.- Parameters:
currentBurstCompletionEvent
- event, that should be executed upon the next completion of a burst of this process.
-