Class AbstractRunQueue
- java.lang.Object
-
- edu.kit.ipd.sdq.pcm.simulation.scheduler.exact.queueing.runqueues.AbstractRunQueue
-
- All Implemented Interfaces:
IRunQueue
- Direct Known Subclasses:
ActiveExpiredRunQueue
,SingleRunQueue
public abstract class AbstractRunQueue extends Object implements IRunQueue
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<IActiveProcess,IResourceInstance>
running_on_table
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractRunQueue()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addProcess(IActiveProcess process, boolean inFront)
Adds a process to the runqueue.protected abstract void
addProcessToRunQueue(IActiveProcess process, boolean inFront)
Template method.boolean
contains(IActiveProcess process)
abstract boolean
containsPending(IActiveProcess process)
Template Method.boolean
containsRunning(IActiveProcess process)
Checks if the runqueue contains a running process.int
getCurrentLoad()
Returns the current number of processes in the ready queues.abstract IActiveProcess
getNextRunnableProcess(IResourceInstance instance)
Returns the next process runnable on the given instance.boolean
isEmpty()
boolean
isIdle(IResourceInstance instance)
True, if there is no process running on the given resource.protected abstract int
numWaitingProcesses()
Template Method.abstract boolean
removePendingProcess(IActiveProcess process)
Template method.boolean
removeProcess(IActiveProcess process)
Removes a process from the runqueue.void
removeRunning(IActiveProcess process)
Removes a running process from the runqueue.IResourceInstance
runningOn(IActiveProcess process)
void
setRunningOn(IActiveProcess process, IResourceInstance instance)
Sets the given process as running on the specified instance.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.kit.ipd.sdq.pcm.simulation.scheduler.exact.queueing.IRunQueue
createNewInstance, getBestRunnableQueue, getNextRunnableProcess, getStarvingProcesses, getWaitingTime, identifyMovableProcesses, processStarving, resetStarvationInfo, setWaitingTime
-
-
-
-
Field Detail
-
running_on_table
protected Map<IActiveProcess,IResourceInstance> running_on_table
-
-
Method Detail
-
getCurrentLoad
public int getCurrentLoad()
Description copied from interface:IRunQueue
Returns the current number of processes in the ready queues.- Specified by:
getCurrentLoad
in interfaceIRunQueue
-
isEmpty
public boolean isEmpty()
-
removeProcess
public boolean removeProcess(IActiveProcess process)
Description copied from interface:IRunQueue
Removes a process from the runqueue.- Specified by:
removeProcess
in interfaceIRunQueue
- Returns:
- True, if the process was removed. False, if the process was not found in the queue.
-
contains
public boolean contains(IActiveProcess process)
-
addProcess
public void addProcess(IActiveProcess process, boolean inFront)
Description copied from interface:IRunQueue
Adds a process to the runqueue.- Specified by:
addProcess
in interfaceIRunQueue
inFront
- If true, the process is added at the beginning of its queue, otherwise it is added at the queue's end.
-
containsRunning
public boolean containsRunning(IActiveProcess process)
Description copied from interface:IRunQueue
Checks if the runqueue contains a running process.- Specified by:
containsRunning
in interfaceIRunQueue
- Parameters:
process
- Process of interest.- Returns:
- True, if the process is in the running list of the runqueue, otherwise false.
-
removeRunning
public void removeRunning(IActiveProcess process)
Description copied from interface:IRunQueue
Removes a running process from the runqueue.- Specified by:
removeRunning
in interfaceIRunQueue
- Parameters:
process
- Process of interest.
-
setRunningOn
public void setRunningOn(IActiveProcess process, IResourceInstance instance)
Description copied from interface:IRunQueue
Sets the given process as running on the specified instance. Note that the process must not be marked as running on another instance.- Specified by:
setRunningOn
in interfaceIRunQueue
- Parameters:
process
- Process to run.instance
- Instance the process shall run on.
-
runningOn
public IResourceInstance runningOn(IActiveProcess process)
-
isIdle
public boolean isIdle(IResourceInstance instance)
Description copied from interface:IRunQueue
True, if there is no process running on the given resource. Furthermore, the pending queue has to be empty if there is only one instance.
-
getNextRunnableProcess
public abstract IActiveProcess getNextRunnableProcess(IResourceInstance instance)
Description copied from interface:IRunQueue
Returns the next process runnable on the given instance.- Specified by:
getNextRunnableProcess
in interfaceIRunQueue
-
containsPending
public abstract boolean containsPending(IActiveProcess process)
Template Method. Returns- Specified by:
containsPending
in interfaceIRunQueue
- Parameters:
process
-- Returns:
-
numWaitingProcesses
protected abstract int numWaitingProcesses()
Template Method. Returns the number of processs waiting in the queue.- Returns:
-
removePendingProcess
public abstract boolean removePendingProcess(IActiveProcess process)
Template method. Removes the given process from the queue.- Specified by:
removePendingProcess
in interfaceIRunQueue
- Parameters:
process
-- Returns:
- True, if the process was successfully removed, otherwise (if the process was not found) false.
-
addProcessToRunQueue
protected abstract void addProcessToRunQueue(IActiveProcess process, boolean inFront)
Template method.- Parameters:
process
-inFront
-
-
-