From 5e3ed0dc3f2c358c415b1a1f8c8fcccd0bfe61c7 Mon Sep 17 00:00:00 2001 From: Maxime Chéramy Date: Mon, 18 May 2015 11:45:30 +0200 Subject: [PATCH] Fix the PriD scheduler. Now gives the highest priority to the k-1 first tasks instead of the k first. Thanks Joeri Biermans. --- schedulers/PriD.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/schedulers/PriD.py b/schedulers/PriD.py index fdc1b17..64edd6e 100644 --- a/schedulers/PriD.py +++ b/schedulers/PriD.py @@ -10,23 +10,24 @@ class PriD(Scheduler): """EDF(k) scheduler""" def init(self): self.ready_list = [] - self.kfirst = [] + self.km1first = [] tasks = sorted(self.task_list, key=lambda x: -x.wcet / x.period) kmin = 1 mmin = None u = sum(x.wcet / x.period for x in tasks) - for k, task in enumerate(tasks): + for km1, task in enumerate(tasks): u -= task.wcet / task.period - m = k + ceil(u / (1 - task.wcet / task.period)) + m = km1 + ceil(u / (1 - task.wcet / task.period)) if mmin is None or mmin > m: - kmin = k + 1 + kmin = km1 + 1 mmin = m - self.kfirst = tasks[:kmin] + # The k-1 first tasks are given the highest priority. + self.km1first = tasks[:kmin - 1] def on_activate(self, job): - if job.task in self.kfirst: + if job.task in self.km1first: job.priority = 0 else: job.priority = job.absolute_deadline -- libgit2 0.26.0