Commit a3663753 by PE Hladik

Add EDCL scheduler

parent 34b6f852
#!/usr/bin/python
# coding=utf-8
__author__ = 'Pierre-Emmanuel Hladik'
from simso.core import Scheduler
class EDCL(Scheduler):
"""
EDCL Scheduler.
Global EDF-based Scheduling with Efficient Priority Promotion.
Shinpei Kato and Nobuyuki Yamasaki.
The 14th International Conference on Embedded and Real-Time Computing
Systems and Applications, 2008
"""
def on_activate(self, job):
job.cpu.resched()
def on_terminated(self, job):
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()
# 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:
job.data['priority'] = 0
else:
job.data['priority'] = job.absolute_deadline
def schedule(self, cpu):
self.update_laxity()
# List of ready jobs not currently running:
ready_jobs = [t.job for t in self.task_list
if t.is_active() and not t.job.is_running()]
if ready_jobs:
# Select a free processor or, if none,
# the one with the greatest deadline (self in case of equality):
key = lambda x: (
1 if not x.running else 0,
x.running.absolute_deadline if x.running else 0,
1 if x is cpu else 0
)
cpu_min = max(self.processors, key=key)
# Select the job with the least priority:
job = min(ready_jobs, key=lambda x: x.data['priority'])
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
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