Commit 6a71b5bc by Maxime Chéramy

Add a laxity property to the Job objects.

parent a3663753
......@@ -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
......
......@@ -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)
......@@ -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)
......
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