Commit 6a71b5bc by Maxime Chéramy

Add a laxity property to the Job objects.

parent a3663753
...@@ -169,16 +169,30 @@ class Job(Process): ...@@ -169,16 +169,30 @@ class Job(Process):
@property @property
def ret(self): def ret(self):
""" """
Remaining execution time. Remaining execution time in ms.
""" """
return self.wcet - self.actual_computation_time return self.wcet - self.actual_computation_time
@property @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): def computation_time(self):
"""
Time spent executing the job in ms.
"""
return float(self.computation_time_cycles) / self._sim.cycles_per_ms return float(self.computation_time_cycles) / self._sim.cycles_per_ms
@property @property
def computation_time_cycles(self): def computation_time_cycles(self):
"""
Time spent executing the job.
"""
if self._last_exec is None: if self._last_exec is None:
return int(self._computation_time) return int(self._computation_time)
else: else:
...@@ -187,6 +201,10 @@ class Job(Process): ...@@ -187,6 +201,10 @@ class Job(Process):
@property @property
def actual_computation_time(self): def actual_computation_time(self):
"""
Computation time in ms as if the processor speed was 1.0 during the
whole execution.
"""
return float( return float(
self.actual_computation_time_cycles) / self._sim.cycles_per_ms self.actual_computation_time_cycles) / self._sim.cycles_per_ms
......
...@@ -21,14 +21,12 @@ class EDCL(Scheduler): ...@@ -21,14 +21,12 @@ class EDCL(Scheduler):
job.cpu.resched() job.cpu.resched()
def update_laxity(self): def update_laxity(self):
for t in self.task_list: for task in self.task_list:
if t.is_active(): if task.is_active():
job = t.job job = task.job
laxity = (job.absolute_deadline - job.ret
) * self.sim.cycles_per_ms - self.sim.now()
# if laxity is less than 0, the job will never respect its deadline, # if laxity is less than 0, the job will never respect its deadline,
# so we do not consider this job as critical # so we do not consider this job as critical
if laxity == 0: if job.laxity == 0:
job.data['priority'] = 0 job.data['priority'] = 0
else: else:
job.data['priority'] = job.absolute_deadline job.data['priority'] = job.absolute_deadline
......
...@@ -58,8 +58,7 @@ class EDZL(Scheduler): ...@@ -58,8 +58,7 @@ class EDZL(Scheduler):
# Recherche du prochain event ZeroLaxity pour configurer le timer. # Recherche du prochain event ZeroLaxity pour configurer le timer.
minimum = None minimum = None
for job in self.ready_list: for job in self.ready_list:
zl_date = int((job.absolute_deadline - job.ret zl_date = job.laxity
) * self.sim.cycles_per_ms - self.sim.now())
if (minimum is None or minimum[0] > zl_date) and zl_date > 0: if (minimum is None or minimum[0] > zl_date) and zl_date > 0:
minimum = (zl_date, job) minimum = (zl_date, job)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment