Class ShortestJobNextScheduler
java.lang.Object
cambio.simulator.resources.cpu.scheduling.CPUProcessScheduler
cambio.simulator.resources.cpu.scheduling.ShortestJobNextScheduler
Scheduler, that schedules all entered processes by their left over work unit demand. Always retrieves the process
that hast he least work left first. Always assigns the full work demand needed for a processes.
- Author:
- Lion Wagner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears all current processes from the scheduler.void
enterProcess
(CPUProcess process) Enters the process into the scheduling queue.int
Calculates the sum of all scheduled process's demand remainders.boolean
Checks whether this scheduler currently has processes ready to be retrieved from scheduling.org.javatuples.Pair<CPUProcess,
Integer> Pulls the nextCPUProcess
to handle and its assigned time/work quantum.org.javatuples.Pair<CPUProcess,
Integer> Pulls the nextCPUProcess
to handle and its assigned time/work quantum.
Prevents automatic rescheduling of the process like in round-robin scheduling.int
size()
Counts the amount of processes that are currently scheduled.
-
Constructor Details
-
ShortestJobNextScheduler
-
-
Method Details
-
enterProcess
Enters the process into the scheduling queue.- Specified by:
enterProcess
in classCPUProcessScheduler
- Parameters:
process
-CPUProcess
that is to be scheduled- See Also:
-
retrieveNextProcess
Pulls the nextCPUProcess
to handle and its assigned time/work quantum.- Specified by:
retrieveNextProcess
in classCPUProcessScheduler
- Returns:
- a pair containing the next
CPUProcess
to handle and its assigned time/work quantum. - See Also:
-
retrieveNextProcessNoReschedule
Pulls the nextCPUProcess
to handle and its assigned time/work quantum.
Prevents automatic rescheduling of the process like in round-robin scheduling.This method is used to offer scheduling for multithreading. But requires manual rescheduling of unfinished processes.
- Specified by:
retrieveNextProcessNoReschedule
in classCPUProcessScheduler
- Returns:
- a pair containing the next
CPUProcess
to handle and its assigned time quantum. - See Also:
-
hasProcessesToSchedule
public boolean hasProcessesToSchedule()Checks whether this scheduler currently has processes ready to be retrieved from scheduling.- Specified by:
hasProcessesToSchedule
in classCPUProcessScheduler
- Returns:
- true if there is a process ready to schedule, false otherwise
-
getTotalWorkDemand
public int getTotalWorkDemand()Calculates the sum of all scheduled process's demand remainders.- Specified by:
getTotalWorkDemand
in classCPUProcessScheduler
- Returns:
- the sum of the demand remainder of all processes that are currently in queue.
-
clear
public void clear()Clears all current processes from the scheduler.- Specified by:
clear
in classCPUProcessScheduler
-
size
public int size()Counts the amount of processes that are currently scheduled.- Specified by:
size
in classCPUProcessScheduler
- Returns:
- the amount of processes that are currently scheduled.
-