From e593c9dbe858c82e284ff85e625837ae3ab32f1c Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Fri, 28 Jan 2011 19:04:08 -0500 Subject: EDF: support priority boosting While we are at it, simplify edf_higher_prio() a bit. --- include/litmus/litmus.h | 3 +++ include/litmus/rt_param.h | 7 +++++++ litmus/edf_common.c | 38 +++++++++++++++++++++++++++----------- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index 8971b25f23e6..b38d39a7461d 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h @@ -54,6 +54,9 @@ void litmus_exit_task(struct task_struct *tsk); #define get_release(t) (tsk_rt(t)->job_params.release) #define get_class(t) (tsk_rt(t)->task_params.cls) +#define is_priority_boosted(t) (tsk_rt(t)->priority_boosted) +#define get_boost_start(t) (tsk_rt(t)->boost_start_time) + inline static int budget_exhausted(struct task_struct* t) { return get_exec_time(t) >= get_exec_cost(t); diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h index a7a183f34a80..5de422c742f6 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h @@ -108,6 +108,13 @@ struct rt_param { /* is the task present? (true if it can be scheduled) */ unsigned int present:1; +#ifdef CONFIG_LITMUS_LOCKING + /* Is the task being priority-boosted by a locking protocol? */ + unsigned int priority_boosted:1; + /* If so, when did this start? */ + lt_t boost_start_time; +#endif + /* user controlled parameters */ struct rt_task task_params; diff --git a/litmus/edf_common.c b/litmus/edf_common.c index 06daec66c984..9b44dc2d8d1e 100644 --- a/litmus/edf_common.c +++ b/litmus/edf_common.c @@ -33,22 +33,38 @@ int edf_higher_prio(struct task_struct* first, } + /* check for NULL tasks */ + if (!first || !second) + return first && !second; + +#ifdef CONFIG_LITMUS_LOCKING + /* Check for inherited priorities. Change task * used for comparison in such a case. */ - if (first && first->rt_param.inh_task) + if (unlikely(first->rt_param.inh_task)) first_task = first->rt_param.inh_task; - if (second && second->rt_param.inh_task) + if (unlikely(second->rt_param.inh_task)) second_task = second->rt_param.inh_task; - return - /* it has to exist in order to have higher priority */ - first_task && ( - /* does the second task exist and is it a real-time task? If - * not, the first task (which is a RT task) has higher - * priority. - */ - !second_task || !is_realtime(second_task) || + /* Check for priority boosting. Tie-break by start of boosting. + */ + if (unlikely(is_priority_boosted(first_task))) { + /* first_task is boosted, how about second_task? */ + if (!is_priority_boosted(second_task) || + lt_before(get_boost_start(first_task), + get_boost_start(second_task))) + return 1; + else + return 0; + } else if (unlikely(is_priority_boosted(second_task))) + /* second_task is boosted, first is not*/ + return 0; + +#endif + + + return !is_realtime(second_task) || /* is the deadline of the first task earlier? * Then it has higher priority. @@ -65,7 +81,7 @@ int edf_higher_prio(struct task_struct* first, * priority wins. */ (first_task->pid == second_task->pid && - !second->rt_param.inh_task)))); + !second->rt_param.inh_task))); } int edf_ready_order(struct bheap_node* a, struct bheap_node* b) -- cgit v1.2.2