aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/sched_gsn_edf.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /litmus/sched_gsn_edf.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'litmus/sched_gsn_edf.c')
-rw-r--r--litmus/sched_gsn_edf.c52
1 files changed, 47 insertions, 5 deletions
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c
index b87524cf1802..d5bb326ebc9b 100644
--- a/litmus/sched_gsn_edf.c
+++ b/litmus/sched_gsn_edf.c
@@ -20,11 +20,16 @@
20#include <litmus/sched_plugin.h> 20#include <litmus/sched_plugin.h>
21#include <litmus/edf_common.h> 21#include <litmus/edf_common.h>
22#include <litmus/sched_trace.h> 22#include <litmus/sched_trace.h>
23#include <litmus/trace.h>
23 24
24#include <litmus/preempt.h> 25#include <litmus/preempt.h>
25 26
26#include <litmus/bheap.h> 27#include <litmus/bheap.h>
27 28
29#ifdef CONFIG_SCHED_CPU_AFFINITY
30#include <litmus/affinity.h>
31#endif
32
28#include <linux/module.h> 33#include <linux/module.h>
29 34
30/* Overview of GSN-EDF operations. 35/* Overview of GSN-EDF operations.
@@ -255,21 +260,52 @@ static noinline void requeue(struct task_struct* task)
255 } 260 }
256} 261}
257 262
263#ifdef CONFIG_SCHED_CPU_AFFINITY
264static cpu_entry_t* gsnedf_get_nearest_available_cpu(cpu_entry_t *start)
265{
266 cpu_entry_t *affinity;
267
268 get_nearest_available_cpu(affinity, start, gsnedf_cpu_entries,
269#ifdef CONFIG_RELEASE_MASTER
270 gsnedf.release_master
271#else
272 NO_CPU
273#endif
274 );
275
276 return(affinity);
277}
278#endif
279
258/* check for any necessary preemptions */ 280/* check for any necessary preemptions */
259static void check_for_preemptions(void) 281static void check_for_preemptions(void)
260{ 282{
261 struct task_struct *task; 283 struct task_struct *task;
262 cpu_entry_t* last; 284 cpu_entry_t *last;
263 285
264 for(last = lowest_prio_cpu(); 286 for (last = lowest_prio_cpu();
265 edf_preemption_needed(&gsnedf, last->linked); 287 edf_preemption_needed(&gsnedf, last->linked);
266 last = lowest_prio_cpu()) { 288 last = lowest_prio_cpu()) {
267 /* preemption necessary */ 289 /* preemption necessary */
268 task = __take_ready(&gsnedf); 290 task = __take_ready(&gsnedf);
269 TRACE("check_for_preemptions: attempting to link task %d to %d\n", 291 TRACE("check_for_preemptions: attempting to link task %d to %d\n",
270 task->pid, last->cpu); 292 task->pid, last->cpu);
293
294#ifdef CONFIG_SCHED_CPU_AFFINITY
295 {
296 cpu_entry_t *affinity =
297 gsnedf_get_nearest_available_cpu(
298 &per_cpu(gsnedf_cpu_entries, task_cpu(task)));
299 if (affinity)
300 last = affinity;
301 else if (last->linked)
302 requeue(last->linked);
303 }
304#else
271 if (last->linked) 305 if (last->linked)
272 requeue(last->linked); 306 requeue(last->linked);
307#endif
308
273 link_task_to_cpu(task, last); 309 link_task_to_cpu(task, last);
274 preempt(last); 310 preempt(last);
275 } 311 }
@@ -376,8 +412,10 @@ static struct task_struct* gsnedf_schedule(struct task_struct * prev)
376 /* Bail out early if we are the release master. 412 /* Bail out early if we are the release master.
377 * The release master never schedules any real-time tasks. 413 * The release master never schedules any real-time tasks.
378 */ 414 */
379 if (gsnedf.release_master == entry->cpu) 415 if (unlikely(gsnedf.release_master == entry->cpu)) {
416 sched_state_task_picked();
380 return NULL; 417 return NULL;
418 }
381#endif 419#endif
382 420
383 raw_spin_lock(&gsnedf_lock); 421 raw_spin_lock(&gsnedf_lock);
@@ -783,6 +821,8 @@ int gsnedf_fmlp_lock(struct litmus_lock* l)
783 set_priority_inheritance(sem->owner, sem->hp_waiter); 821 set_priority_inheritance(sem->owner, sem->hp_waiter);
784 } 822 }
785 823
824 TS_LOCK_SUSPEND;
825
786 /* release lock before sleeping */ 826 /* release lock before sleeping */
787 spin_unlock_irqrestore(&sem->wait.lock, flags); 827 spin_unlock_irqrestore(&sem->wait.lock, flags);
788 828
@@ -793,6 +833,8 @@ int gsnedf_fmlp_lock(struct litmus_lock* l)
793 833
794 schedule(); 834 schedule();
795 835
836 TS_LOCK_RESUME;
837
796 /* Since we hold the lock, no other task will change 838 /* Since we hold the lock, no other task will change
797 * ->owner. We can thus check it without acquiring the spin 839 * ->owner. We can thus check it without acquiring the spin
798 * lock. */ 840 * lock. */