aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2011-01-28 19:04:08 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2011-02-01 16:30:41 -0500
commite593c9dbe858c82e284ff85e625837ae3ab32f1c (patch)
treeef1b5a608545ddf276517b85f57999c925242627
parentfc6482bb7a6a638474565c90159997bd59069297 (diff)
EDF: support priority boosting
While we are at it, simplify edf_higher_prio() a bit.
-rw-r--r--include/litmus/litmus.h3
-rw-r--r--include/litmus/rt_param.h7
-rw-r--r--litmus/edf_common.c38
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);
54#define get_release(t) (tsk_rt(t)->job_params.release) 54#define get_release(t) (tsk_rt(t)->job_params.release)
55#define get_class(t) (tsk_rt(t)->task_params.cls) 55#define get_class(t) (tsk_rt(t)->task_params.cls)
56 56
57#define is_priority_boosted(t) (tsk_rt(t)->priority_boosted)
58#define get_boost_start(t) (tsk_rt(t)->boost_start_time)
59
57inline static int budget_exhausted(struct task_struct* t) 60inline static int budget_exhausted(struct task_struct* t)
58{ 61{
59 return get_exec_time(t) >= get_exec_cost(t); 62 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 {
108 /* is the task present? (true if it can be scheduled) */ 108 /* is the task present? (true if it can be scheduled) */
109 unsigned int present:1; 109 unsigned int present:1;
110 110
111#ifdef CONFIG_LITMUS_LOCKING
112 /* Is the task being priority-boosted by a locking protocol? */
113 unsigned int priority_boosted:1;
114 /* If so, when did this start? */
115 lt_t boost_start_time;
116#endif
117
111 /* user controlled parameters */ 118 /* user controlled parameters */
112 struct rt_task task_params; 119 struct rt_task task_params;
113 120
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,
33 } 33 }
34 34
35 35
36 /* check for NULL tasks */
37 if (!first || !second)
38 return first && !second;
39
40#ifdef CONFIG_LITMUS_LOCKING
41
36 /* Check for inherited priorities. Change task 42 /* Check for inherited priorities. Change task
37 * used for comparison in such a case. 43 * used for comparison in such a case.
38 */ 44 */
39 if (first && first->rt_param.inh_task) 45 if (unlikely(first->rt_param.inh_task))
40 first_task = first->rt_param.inh_task; 46 first_task = first->rt_param.inh_task;
41 if (second && second->rt_param.inh_task) 47 if (unlikely(second->rt_param.inh_task))
42 second_task = second->rt_param.inh_task; 48 second_task = second->rt_param.inh_task;
43 49
44 return 50 /* Check for priority boosting. Tie-break by start of boosting.
45 /* it has to exist in order to have higher priority */ 51 */
46 first_task && ( 52 if (unlikely(is_priority_boosted(first_task))) {
47 /* does the second task exist and is it a real-time task? If 53 /* first_task is boosted, how about second_task? */
48 * not, the first task (which is a RT task) has higher 54 if (!is_priority_boosted(second_task) ||
49 * priority. 55 lt_before(get_boost_start(first_task),
50 */ 56 get_boost_start(second_task)))
51 !second_task || !is_realtime(second_task) || 57 return 1;
58 else
59 return 0;
60 } else if (unlikely(is_priority_boosted(second_task)))
61 /* second_task is boosted, first is not*/
62 return 0;
63
64#endif
65
66
67 return !is_realtime(second_task) ||
52 68
53 /* is the deadline of the first task earlier? 69 /* is the deadline of the first task earlier?
54 * Then it has higher priority. 70 * Then it has higher priority.
@@ -65,7 +81,7 @@ int edf_higher_prio(struct task_struct* first,
65 * priority wins. 81 * priority wins.
66 */ 82 */
67 (first_task->pid == second_task->pid && 83 (first_task->pid == second_task->pid &&
68 !second->rt_param.inh_task)))); 84 !second->rt_param.inh_task)));
69} 85}
70 86
71int edf_ready_order(struct bheap_node* a, struct bheap_node* b) 87int edf_ready_order(struct bheap_node* a, struct bheap_node* b)