Go backward to Node : Network NodesGo up to 4.1 Types Go forward to Selector : Message Selectors |
Scheduler
: Program Schedulersabstract class Scheduler { int getNumber() boolean isReady(int i) int getTime(int i) abstract int nextProgram() }
A scheduler selects the next program for execution among those node programs
that are in the ready state. A scheduler must redefine the abstract
function nextProgram()
such that this function returns some i
with 0 <= i < getNumber()
and isReady(i)
(i.e. it must select one ready node program for execution). If this condition
cannot be fulfilled, the scheduler must return -1 (denoting deadlock). The function getTime(i)
returns the (simulation) time elapsed for program i which may be used for the scheduling decision.
The default scheduler selects in a round robin mechanism the next program ready for execution; it is an object of type
class SchedulerDefault extends Scheduler { int last = -1; int nextProgram() { int n = getNumber(); boolean reset = false; do { last++; if (last == n) { last = 0; if (reset) return -1; reset = true; } } while (!isReady(last)); return last; } }
The default scheduler may be redefined to implement different kinds of network models (synchronized networks, asynchronous networks, ...).
The following schedulers are currently predefined:
SchedulerMinTime
: Selects the ready program with the minimum elapsed time.
SchedulerMaxTime
: Selects the ready program with the maximum elapsed time.