diff options
Diffstat (limited to 'litmus/sched_gsn_edf.c')
-rw-r--r-- | litmus/sched_gsn_edf.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c index 3092797480f8..17926e9fccdc 100644 --- a/litmus/sched_gsn_edf.c +++ b/litmus/sched_gsn_edf.c | |||
@@ -23,6 +23,10 @@ | |||
23 | 23 | ||
24 | #include <litmus/bheap.h> | 24 | #include <litmus/bheap.h> |
25 | 25 | ||
26 | #ifdef CONFIG_SCHED_CPU_AFFINITY | ||
27 | #include <litmus/affinity.h> | ||
28 | #endif | ||
29 | |||
26 | #include <linux/module.h> | 30 | #include <linux/module.h> |
27 | 31 | ||
28 | /* Overview of GSN-EDF operations. | 32 | /* Overview of GSN-EDF operations. |
@@ -253,21 +257,52 @@ static noinline void requeue(struct task_struct* task) | |||
253 | } | 257 | } |
254 | } | 258 | } |
255 | 259 | ||
260 | #ifdef CONFIG_SCHED_CPU_AFFINITY | ||
261 | static cpu_entry_t* gsnedf_get_nearest_available_cpu(cpu_entry_t* start) | ||
262 | { | ||
263 | cpu_entry_t* affinity; | ||
264 | |||
265 | get_nearest_available_cpu(affinity, start, gsnedf_cpu_entries, | ||
266 | #ifdef CONFIG_RELEASE_MASTER | ||
267 | gsnedf.release_master | ||
268 | #else | ||
269 | -1 | ||
270 | #endif | ||
271 | ); | ||
272 | |||
273 | return(affinity); | ||
274 | } | ||
275 | #endif | ||
276 | |||
256 | /* check for any necessary preemptions */ | 277 | /* check for any necessary preemptions */ |
257 | static void check_for_preemptions(void) | 278 | static void check_for_preemptions(void) |
258 | { | 279 | { |
259 | struct task_struct *task; | 280 | struct task_struct *task; |
260 | cpu_entry_t* last; | 281 | cpu_entry_t* last; |
261 | 282 | ||
262 | for(last = lowest_prio_cpu(); | 283 | for (last = lowest_prio_cpu(); |
263 | edf_preemption_needed(&gsnedf, last->linked); | 284 | edf_preemption_needed(&gsnedf, last->linked); |
264 | last = lowest_prio_cpu()) { | 285 | last = lowest_prio_cpu()) { |
265 | /* preemption necessary */ | 286 | /* preemption necessary */ |
266 | task = __take_ready(&gsnedf); | 287 | task = __take_ready(&gsnedf); |
267 | TRACE("check_for_preemptions: attempting to link task %d to %d\n", | 288 | TRACE("check_for_preemptions: attempting to link task %d to %d\n", |
268 | task->pid, last->cpu); | 289 | task->pid, last->cpu); |
290 | |||
291 | #ifdef CONFIG_SCHED_CPU_AFFINITY | ||
292 | { | ||
293 | cpu_entry_t* affinity = | ||
294 | gsnedf_get_nearest_available_cpu( | ||
295 | &per_cpu(gsnedf_cpu_entries, task_cpu(task))); | ||
296 | if (affinity) | ||
297 | last = affinity; | ||
298 | else if (last->linked) | ||
299 | requeue(last->linked); | ||
300 | } | ||
301 | #else | ||
269 | if (last->linked) | 302 | if (last->linked) |
270 | requeue(last->linked); | 303 | requeue(last->linked); |
304 | #endif | ||
305 | |||
271 | link_task_to_cpu(task, last); | 306 | link_task_to_cpu(task, last); |
272 | preempt(last); | 307 | preempt(last); |
273 | } | 308 | } |