Scheduler

Contents


Adding A New Algorithm

Adding a new algorithm to Scheduler does not require modifying the code in the program, nor compiling it again.

It is just needed to create a class inheriting tools.Algorithm, that implements the algorithm needed. The .class file must then be moved to directory <Scheduler>/tools/algorithms and it will be taken in account at the next running of Scheduler.

This class inheriting Algorithm must follow these rules:

  • It must be part of package tools.algorithms.
  • The new algorithm must override the getName() which returns a String that contains the name of the algorithm:
    public String getName(). This character string will be displayed in the list of available algorithms. If the method is not overriden, an error will occur at compile-time (it is declared as abstract in class Algorithm).
  • The new algorithm must override the Task getNextTask() method, returning the task currently excuted by the CPU. This task is chosen among the tasks available in TaskStack.

If necessary, the new algorithm may override the boolean isTaskParamOK() and boolean isSchedulable() methods. These are implemented in class Algorithm and their default behaviour is to return true.

  • boolean isTaskParamOK() tests if the parameters of each task are valid for the current algorithm. For example, Rate Monotonic demands that all tasks be periodic, and that their period be equal to their deadline.
  • boolean isSchedulable() tests if the tasks are schedulable "as is" with this algorithm (i.e. if it is possible to schedule them without missed deadlines). If not, a warning is displayed, but the user can resume the simulation.

Once the code for the algorithm is written, it is necessary to compile (e.g. using javac tools/algorithme/AlgorithmName.java) and make sure the .class file produced is placed in directory <Scheduler>/tools/algorithms, so that it can be taken in account automatically when starting Scheduler.


Contents