Class CPUProcess

java.lang.Object
cambio.simulator.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 latter.

For the purpose of compatibility (e.g. non impacting operations) a demand of 0 is allowed.

Author:
Lion Wagner
  • 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

      public CPUProcess(Request request)
      Creates a CPUProcess for the given Request.
      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 calculated
      computingCapacityPerTimeUnit - computing capacity of a thread per time unit
      Returns:
      the remaining demand of the currently handled process
    • getRequest

      public Request getRequest()
    • compareTo

      public int compareTo(CPUProcess other)
      Natural sorting is based on left over demand.
      Specified by:
      compareTo in interface Comparable<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.