java.lang.Object
de.rss.fachstudie.MiSim.resources.cpu.scheduling.CPUProcessScheduler
de.rss.fachstudie.MiSim.resources.cpu.scheduling.MLFQScheduler

public class MLFQScheduler
extends CPUProcessScheduler
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 Details

    • MLFQScheduler

      public MLFQScheduler​(String name)
    • MLFQScheduler

      public MLFQScheduler​(String name, int layer_count)
  • Method Details

    • enterProcess

      public void enterProcess​(CPUProcess process)
      Enters the process into the scheduling queue.
      Specified by:
      enterProcess in class CPUProcessScheduler
      Parameters:
      process - Process that is to be scheduled
      See Also:
      CPUProcess
    • retrieveNextProcess

      public org.javatuples.Pair<CPUProcess,​Integer> retrieveNextProcess()
      Pulls the next Process to handle and how much demand should be accomplished.
      Specified by:
      retrieveNextProcess in class CPUProcessScheduler
      Returns:
      a pair containing the next process to handle and how much demand should be accomplished.
      See Also:
      CPUProcess
    • retrieveNextProcessNoReschedule

      public org.javatuples.Pair<CPUProcess,​Integer> 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 class CPUProcessScheduler
      Returns:
      a pair containing the next process to handle and its assigned time quantum.
      See Also:
      CPUProcess
    • hasThreadsToSchedule

      public boolean hasThreadsToSchedule()
      Specified by:
      hasThreadsToSchedule in class CPUProcessScheduler
      Returns:
      true if there is a thread ready to schedule, false otherwise
    • getTotalWorkDemand

      public int getTotalWorkDemand()
      Specified by:
      getTotalWorkDemand in class CPUProcessScheduler
      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 class CPUProcessScheduler
    • size

      public int size()
      Specified by:
      size in class CPUProcessScheduler