diff options
Diffstat (limited to 'litmus/edf_common.c')
-rwxr-xr-x | litmus/edf_common.c | 78 |
1 files changed, 33 insertions, 45 deletions
diff --git a/litmus/edf_common.c b/litmus/edf_common.c index 5a3f5b417f73..c279bf12a7f5 100755 --- a/litmus/edf_common.c +++ b/litmus/edf_common.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <litmus/fpmath.h> | 22 | #include <litmus/fpmath.h> |
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | #if defined(CONFIG_EDF_TIE_BREAK_HASH) || defined(CONFIG_REALTIME_AUX_TASKS) | 25 | #if defined(CONFIG_EDF_TIE_BREAK_HASH) |
26 | #include <linux/hash.h> | 26 | #include <linux/hash.h> |
27 | static inline long edf_hash(struct task_struct *t) | 27 | static inline long edf_hash(struct task_struct *t) |
28 | { | 28 | { |
@@ -43,23 +43,6 @@ static inline long edf_hash(struct task_struct *t) | |||
43 | } | 43 | } |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #ifdef CONFIG_REALTIME_AUX_TASK_PRIORITY_INHERITANCE | ||
47 | int aux_tie_break(struct task_struct *first, struct task_struct *second) | ||
48 | { | ||
49 | long fhash = edf_hash(first); | ||
50 | long shash = edf_hash(second); | ||
51 | if (fhash < shash) { | ||
52 | TRACE_CUR("%s/%d >> %s/%d --- %d\n", first->comm, first->pid, second->comm, second->pid, 1); | ||
53 | return 1; | ||
54 | } | ||
55 | else if(fhash == shash) { | ||
56 | TRACE_CUR("%s/%d >> %s/%d --- %d\n", first->comm, first->pid, second->comm, second->pid, (first->pid < second->pid)); | ||
57 | return first->pid < second->pid; | ||
58 | } | ||
59 | return 0; | ||
60 | } | ||
61 | #endif | ||
62 | |||
63 | 46 | ||
64 | /* edf_higher_prio - returns true if first has a higher EDF priority | 47 | /* edf_higher_prio - returns true if first has a higher EDF priority |
65 | * than second. Deadline ties are broken by PID. | 48 | * than second. Deadline ties are broken by PID. |
@@ -93,44 +76,47 @@ int edf_higher_prio(struct task_struct* first, struct task_struct* second) | |||
93 | 76 | ||
94 | #if defined(CONFIG_REALTIME_AUX_TASK_PRIORITY_BOOSTED) | 77 | #if defined(CONFIG_REALTIME_AUX_TASK_PRIORITY_BOOSTED) |
95 | /* run aux tasks at max priority */ | 78 | /* run aux tasks at max priority */ |
79 | /* TODO: Actually use prio-boosting. */ | ||
96 | if (first->rt_param.is_aux_task != second->rt_param.is_aux_task) | 80 | if (first->rt_param.is_aux_task != second->rt_param.is_aux_task) |
97 | { | 81 | { |
98 | return (first->rt_param.is_aux_task > second->rt_param.is_aux_task); | 82 | return (first->rt_param.is_aux_task > second->rt_param.is_aux_task); |
99 | } | 83 | } |
100 | else if(first->rt_param.is_aux_task && second->rt_param.is_aux_task) | 84 | else if(first->rt_param.is_aux_task && second->rt_param.is_aux_task) |
101 | { | 85 | { |
86 | if(first->group_leader == second->group_leader) { | ||
87 | TRACE_CUR("aux tie break!\n"); // tie-break by BASE priority of the aux tasks | ||
88 | goto aux_tie_break; | ||
89 | } | ||
102 | first = first->group_leader; | 90 | first = first->group_leader; |
103 | second = second->group_leader; | 91 | second = second->group_leader; |
104 | } | 92 | } |
105 | #elif defined(CONFIG_REALTIME_AUX_TASK_PRIORITY_INHERITANCE) | 93 | #elif defined(CONFIG_REALTIME_AUX_TASK_PRIORITY_INHERITANCE) |
106 | { | 94 | { |
107 | int first_lo_aux, second_lo_aux; | 95 | int first_lo_aux = first->rt_param.is_aux_task && !first->rt_param.inh_task; |
108 | int first_hi_aux, second_hi_aux; | 96 | int second_lo_aux = second->rt_param.is_aux_task && !second->rt_param.inh_task; |
109 | first_lo_aux = first->rt_param.is_aux_task && !first->rt_param.inh_task; | 97 | |
110 | second_lo_aux = second->rt_param.is_aux_task && !second->rt_param.inh_task; | 98 | /* prioritize aux tasks without inheritance below real-time tasks */ |
111 | 99 | if (first_lo_aux || second_lo_aux) { | |
112 | if (first_lo_aux && !second_lo_aux) { | 100 | // one of these is an aux task without inheritance. |
113 | TRACE_CUR("%s/%d >> %s/%d --- 0\n", first->comm, first->pid, second->comm, second->pid); | 101 | if(first_lo_aux && second_lo_aux) { |
114 | return 0; | 102 | TRACE_CUR("aux tie break!\n"); // tie-break by BASE priority of the aux tasks |
115 | } | 103 | goto aux_tie_break; |
116 | else if (second_lo_aux && !first_lo_aux) { | 104 | } |
117 | TRACE_CUR("%s/%d >> %s/%d --- 1\n", first->comm, first->pid, second->comm, second->pid); | 105 | else { |
118 | return 1; | 106 | // make the aux thread lowest priority real-time task |
119 | } | 107 | int temp = (first_lo_aux) ? !is_realtime(second) : !is_realtime(first); |
120 | else if (first_lo_aux && second_lo_aux) { | 108 | TRACE_CUR("%s/%d >> %s/%d --- %d\n", first->comm, first->pid, second->comm, second->pid, temp); |
121 | int aux_lo_tie_break = aux_tie_break(first, second); | 109 | return temp; |
122 | TRACE_CUR("low aux tie break: %s/%d >> %s/%d --- %d\n", first->comm, first->pid, second->comm, second->pid, aux_lo_tie_break); | 110 | } |
123 | return aux_lo_tie_break; | 111 | } |
124 | } | 112 | |
125 | 113 | if (first->rt_param.is_aux_task && second->rt_param.is_aux_task && | |
126 | first_hi_aux = first->rt_param.is_aux_task && first->rt_param.inh_task; | 114 | first->rt_param.inh_task == second->rt_param.inh_task) { // inh_task is !NULL for both tasks since neither was a lo_aux task |
127 | second_hi_aux = second->rt_param.is_aux_task && second->rt_param.inh_task; | 115 | // Both aux tasks inherit from the same task, so tie-break |
128 | 116 | // by base priority of the aux tasks. | |
129 | if (first_hi_aux && second_hi_aux && first->rt_param.inh_task == second->rt_param.inh_task) { | 117 | TRACE_CUR("aux tie break!\n"); |
130 | int aux_hi_tie_break = aux_tie_break(first, second); | 118 | goto aux_tie_break; |
131 | TRACE_CUR("hi aux tie break: %s/%d >> %s/%d --- %d\n", first->comm, first->pid, second->comm, second->pid, aux_hi_tie_break); | 119 | } |
132 | return aux_hi_tie_break; | ||
133 | } | ||
134 | } | 120 | } |
135 | #endif | 121 | #endif |
136 | 122 | ||
@@ -174,6 +160,8 @@ int edf_higher_prio(struct task_struct* first, struct task_struct* second) | |||
174 | 160 | ||
175 | #endif | 161 | #endif |
176 | 162 | ||
163 | aux_tie_break: | ||
164 | |||
177 | if (!is_realtime(second_task)) { | 165 | if (!is_realtime(second_task)) { |
178 | return 1; | 166 | return 1; |
179 | } | 167 | } |