From f5bf97f1f5345f7e8aef2b99ec0d57ddd081c1d2 Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Fri, 27 Sep 2013 13:53:31 -0400 Subject: Add PGM support to C-EDF. Patch adds PGM priority boosting (and un-boosting) to C-EDF. --- litmus/sched_cedf.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c index 7cb3cc07ed21..b6bed80133f7 100644 --- a/litmus/sched_cedf.c +++ b/litmus/sched_cedf.c @@ -48,6 +48,10 @@ #include #endif +#ifdef CONFIG_SCHED_PGM +#include +#endif + /* to configure the cluster size */ #include #include @@ -459,6 +463,42 @@ static struct task_struct* cedf_schedule(struct task_struct * prev) TRACE_TASK(prev, "will be preempted by %s/%d\n", entry->linked->comm, entry->linked->pid); +#ifdef CONFIG_SCHED_PGM + if (exists && is_pgm_waiting(entry->scheduled)) { + if (!is_priority_boosted(entry->scheduled)) { + TRACE_TASK(entry->scheduled, "is waiting for PGM tokens.\n"); + BUG_ON(is_pgm_satisfied(entry->scheduled)); + + /* Boost priority so we'll be scheduled immediately + when needed tokens arrive. */ + tsk_rt(entry->scheduled)->priority_boosted = 1; + tsk_rt(entry->scheduled)->boost_start_time = litmus_clock(); + + if (unlikely(!blocks)) { + /* Task has probably blocked on an inbound token socket, but + if not, re-evaluate scheduling decisions */ + unlink(entry->scheduled); + cedf_job_arrival(entry->scheduled); + } + } + else if (is_pgm_satisfied(entry->scheduled)) { + TRACE_TASK(entry->scheduled, "is done waiting for PGM tokens.\n"); + BUG_ON(!is_priority_boosted(entry->scheduled)); + + /* clear any boosting */ + tsk_rt(entry->scheduled)->priority_boosted = 0; + setup_pgm_release(entry->scheduled); + + if (likely(!blocks)) { + /* Task has probably called sched_yield(), so blocking is + unlikely. Re-evaluate scheduling decisions because we + still want to run. */ + unlink(entry->scheduled); + cedf_job_arrival(entry->scheduled); + } + } + } +#endif /* If a task blocks we have no choice but to reschedule. */ -- cgit v1.2.2