Class CPUProcess
java.lang.Object
de.rss.fachstudie.MiSim.resources.cpu.CPUProcess
- All Implemented Interfaces:
Comparable<CPUProcess>
public final class CPUProcess extends Object implements 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 later.
For the purpose of compatibility (e.g. non impacting operations) a demand of 0 is allowed.
- Author:
- Lion Wagner
-
Constructor Summary
Constructors Constructor Description CPUProcess(int demandTotal)Constructor that can be used to create artificial load onto the systemCPUProcess(Request request)Creates aCPUProcessfor the givenRequest. -
Method Summary
Modifier and Type Method Description voidcancel()Cancels the current Burst of the this process and reset its progress.intcompareTo(CPUProcess o)Natural sorting is based on left over demand.intgetDemandRemainder()doublegetDemandRemainder(desmoj.core.simulator.TimeInstant peekTime, int computingCapacityPerTimeUnit)Calculates the time/work left for the current burst of this processes at the specific point int time.intgetDemandTotal()RequestgetRequest()voidreduceDemandRemainder(int amount)voidsetCurrentBurstCompletionEvent(ComputationBurstCompletedEvent currentBurstCompletionEvent)Sets the event, that should be executed upon the next completion of a burst of this process.voidstampCurrentBurstStarted(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 aCPUProcessfor the givenRequest.- Parameters:
request-Requestthat should be represent by this process.
-
-
Method Details
-
getDemandTotal
public int getDemandTotal() -
getDemandRemainder
public int getDemandRemainder()- Returns:
- the remaining demand units before the start of the latest burst.
-
getDemandRemainder
public double getDemandRemainder(desmoj.core.simulator.TimeInstant peekTime, int 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:
compareToin interfaceComparable<CPUProcess>
-
reduceDemandRemainder
public void reduceDemandRemainder(int amount)- 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 the 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.
-