Class MultiLevelFeedbackQueueScheduler
java.lang.Object
cambio.simulator.resources.cpu.scheduling.CPUProcessScheduler
cambio.simulator.resources.cpu.scheduling.MultiLevelFeedbackQueueScheduler
Implements a Multi-Level Feedback Queue scheduler.
Entering processes will be put into a high priority round robin queue. If the processes is not completed after the first round it drops down to next lower level (also a round robin queue). This can continue until the processes arrives at the lowest level. There, a normal round robin scheduling is employed.
This scheduler always prioritizes higher levels over lower levels. Therefore, short and recently arrived processes are prioritized, while long running processes are handled with lower priority. Fairness is not guaranteed with this implementation.
The number of Queues can be adjusted by using the "level" parameter of the constructor. Default value is 3.
- Author:
- Lion Wagner
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new 3-layer multi level feedback queue.MultiLevelFeedbackQueueScheduler
(String name, int layerCount) Creates a new n-layer multi level feedback queue. -
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 next Process to handle and how much demand should be accomplished.org.javatuples.Pair<CPUProcess,
Integer> Pulls the next Process 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
-
MultiLevelFeedbackQueueScheduler
Creates a new 3-layer multi level feedback queue.- Parameters:
name
- name of the scheduler
-
MultiLevelFeedbackQueueScheduler
Creates a new n-layer multi level feedback queue.- Parameters:
name
- name of the schedulerlayerCount
- number of target layers
-
-
Method Details
-
enterProcess
Enters the process into the scheduling queue.- Specified by:
enterProcess
in classCPUProcessScheduler
- Parameters:
process
- Process that is to be scheduled- See Also:
-
retrieveNextProcess
Pulls the next Process to handle and how much demand should be accomplished.- Specified by:
retrieveNextProcess
in classCPUProcessScheduler
- Returns:
- a pair containing the next process to handle and how much demand should be accomplished.
- See Also:
-
retrieveNextProcessNoReschedule
Pulls the next Process 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.
- Specified by:
retrieveNextProcessNoReschedule
in classCPUProcessScheduler
- Returns:
- a pair containing the next process 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.
-