From 6a71b5bc318cd3344e2ddf51d550e2b89326929c Mon Sep 17 00:00:00 2001 From: Maxime Chéramy Date: Thu, 28 May 2015 11:36:28 +0200 Subject: [PATCH] Add a laxity property to the Job objects. --- simso/core/Job.py | 20 +++++++++++++++++++- simso/schedulers/EDCL.py | 12 +++++------- simso/schedulers/EDZL.py | 3 +-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/simso/core/Job.py b/simso/core/Job.py index 92c32d1..4708fd3 100644 --- a/simso/core/Job.py +++ b/simso/core/Job.py @@ -169,16 +169,30 @@ class Job(Process): @property def ret(self): """ - Remaining execution time. + Remaining execution time in ms. """ return self.wcet - self.actual_computation_time @property + def laxity(self): + """ + Dynamic laxity of the job in ms. + """ + return (self.absolute_deadline - self.ret + ) * self.sim.cycles_per_ms - self.sim.now() + + @property def computation_time(self): + """ + Time spent executing the job in ms. + """ return float(self.computation_time_cycles) / self._sim.cycles_per_ms @property def computation_time_cycles(self): + """ + Time spent executing the job. + """ if self._last_exec is None: return int(self._computation_time) else: @@ -187,6 +201,10 @@ class Job(Process): @property def actual_computation_time(self): + """ + Computation time in ms as if the processor speed was 1.0 during the + whole execution. + """ return float( self.actual_computation_time_cycles) / self._sim.cycles_per_ms diff --git a/simso/schedulers/EDCL.py b/simso/schedulers/EDCL.py index 4c03b69..21a25d2 100644 --- a/simso/schedulers/EDCL.py +++ b/simso/schedulers/EDCL.py @@ -21,14 +21,12 @@ class EDCL(Scheduler): job.cpu.resched() def update_laxity(self): - for t in self.task_list: - if t.is_active(): - job = t.job - laxity = (job.absolute_deadline - job.ret - ) * self.sim.cycles_per_ms - self.sim.now() + for task in self.task_list: + if task.is_active(): + job = task.job # if laxity is less than 0, the job will never respect its deadline, # so we do not consider this job as critical - if laxity == 0: + if job.laxity == 0: job.data['priority'] = 0 else: job.data['priority'] = job.absolute_deadline @@ -54,4 +52,4 @@ class EDCL(Scheduler): if (cpu_min.running is None or cpu_min.running.absolute_deadline > job.absolute_deadline): - return (job, cpu_min) \ No newline at end of file + return (job, cpu_min) diff --git a/simso/schedulers/EDZL.py b/simso/schedulers/EDZL.py index 1423125..815187f 100644 --- a/simso/schedulers/EDZL.py +++ b/simso/schedulers/EDZL.py @@ -58,8 +58,7 @@ class EDZL(Scheduler): # Recherche du prochain event ZeroLaxity pour configurer le timer. minimum = None for job in self.ready_list: - zl_date = int((job.absolute_deadline - job.ret - ) * self.sim.cycles_per_ms - self.sim.now()) + zl_date = job.laxity if (minimum is None or minimum[0] > zl_date) and zl_date > 0: minimum = (zl_date, job) -- libgit2 0.26.0