/* Move-To-Rear List Scheduling: a new scheduling algorithm for providing QoS guarantees: Bruno, Gabber, \"Ozden, Silberschatz, 1997 Since Bossa doesn't give us a global list, we have to use numbers to record the position a process would have in such a list. Unfortunately, these numbers grow indefinitely, so the policy is susceptible to integer overflow. */ module MTR(RUNNING process running) { process = { requires int proportion; int index; int ticks; } requires int MaxProp; int period = 10; int min_index = 0; ordering_criteria = { lowest index } handler (event e) { On system.clocktick { running.ticks--; if (running.ticks <= 0) { running.index = min_index; min_index++; running.ticks = (running.proportion * period) / MaxProp; } } } interface = { void set_period (int new_period) { foreach (p) { int current_total_ticks = (p.proportion * period) / MaxProp; int new_total_ticks = (p.proportion * new_period) / MaxProp; p.ticks = (p.ticks * new_total_ticks) / current_total_ticks; } period = new_period; } void attach(requires process p) { p.index = min_index; min_index++; p.ticks = (p.proportion * period) / MaxProp; next(); } } }