diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2009-04-29 13:01:48 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2009-04-29 13:01:48 -0400 |
commit | e8327a6d1a1df73efba8d1492f604a51bd6322c3 (patch) | |
tree | a883629eaf9dd49f8a80ec70ac2a5e5e902d9cc9 | |
parent | 671c26683c0ec93b5cd092101363f0741cc4c9c1 (diff) |
GSN-EDF: add release master support
-rw-r--r-- | litmus/sched_gsn_edf.c | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c index e350d5668f..0d24244bee 100644 --- a/litmus/sched_gsn_edf.c +++ b/litmus/sched_gsn_edf.c | |||
@@ -393,6 +393,12 @@ static struct task_struct* gsnedf_schedule(struct task_struct * prev) | |||
393 | int out_of_time, sleep, preempt, np, exists, blocks; | 393 | int out_of_time, sleep, preempt, np, exists, blocks; |
394 | struct task_struct* next = NULL; | 394 | struct task_struct* next = NULL; |
395 | 395 | ||
396 | /* Bail out early if we are the release master. | ||
397 | * The release master never schedules any real-time tasks. | ||
398 | */ | ||
399 | if (gsnedf.release_master == entry->cpu) | ||
400 | return NULL; | ||
401 | |||
396 | spin_lock(&gsnedf_lock); | 402 | spin_lock(&gsnedf_lock); |
397 | clear_will_schedule(); | 403 | clear_will_schedule(); |
398 | 404 | ||
@@ -508,18 +514,23 @@ static void gsnedf_task_new(struct task_struct * t, int on_rq, int running) | |||
508 | TRACE("gsn edf: task new %d\n", t->pid); | 514 | TRACE("gsn edf: task new %d\n", t->pid); |
509 | 515 | ||
510 | spin_lock_irqsave(&gsnedf_lock, flags); | 516 | spin_lock_irqsave(&gsnedf_lock, flags); |
517 | |||
518 | /* setup job params */ | ||
519 | release_at(t, litmus_clock()); | ||
520 | |||
511 | if (running) { | 521 | if (running) { |
512 | entry = &per_cpu(gsnedf_cpu_entries, task_cpu(t)); | 522 | entry = &per_cpu(gsnedf_cpu_entries, task_cpu(t)); |
513 | BUG_ON(entry->scheduled); | 523 | BUG_ON(entry->scheduled); |
514 | entry->scheduled = t; | 524 | if (entry->cpu != gsnedf.release_master) { |
515 | t->rt_param.scheduled_on = task_cpu(t); | 525 | entry->scheduled = t; |
516 | } else | 526 | tsk_rt(t)->scheduled_on = task_cpu(t); |
527 | } else | ||
528 | tsk_rt(t)->scheduled_on = NO_CPU; | ||
529 | } else { | ||
517 | t->rt_param.scheduled_on = NO_CPU; | 530 | t->rt_param.scheduled_on = NO_CPU; |
531 | } | ||
518 | t->rt_param.linked_on = NO_CPU; | 532 | t->rt_param.linked_on = NO_CPU; |
519 | 533 | ||
520 | /* setup job params */ | ||
521 | release_at(t, litmus_clock()); | ||
522 | |||
523 | gsnedf_job_arrival(t); | 534 | gsnedf_job_arrival(t); |
524 | spin_unlock_irqrestore(&gsnedf_lock, flags); | 535 | spin_unlock_irqrestore(&gsnedf_lock, flags); |
525 | } | 536 | } |
@@ -678,6 +689,29 @@ static long gsnedf_admit_task(struct task_struct* tsk) | |||
678 | return 0; | 689 | return 0; |
679 | } | 690 | } |
680 | 691 | ||
692 | static long gsnedf_activate_plugin(void) | ||
693 | { | ||
694 | int cpu; | ||
695 | cpu_entry_t *entry; | ||
696 | |||
697 | heap_init(&gsnedf_cpu_heap); | ||
698 | gsnedf.release_master = atomic_read(&release_master_cpu); | ||
699 | |||
700 | for_each_online_cpu(cpu) { | ||
701 | entry = &per_cpu(gsnedf_cpu_entries, cpu); | ||
702 | heap_node_init(&entry->hn, entry); | ||
703 | atomic_set(&entry->will_schedule, 0); | ||
704 | entry->linked = NULL; | ||
705 | entry->scheduled = NULL; | ||
706 | if (cpu != gsnedf.release_master) { | ||
707 | TRACE("GSN-EDF: Initializing CPU #%d.\n", cpu); | ||
708 | update_cpu_position(entry); | ||
709 | } else { | ||
710 | TRACE("GSN-EDF: CPU %d is release master.\n", cpu); | ||
711 | } | ||
712 | } | ||
713 | return 0; | ||
714 | } | ||
681 | 715 | ||
682 | /* Plugin object */ | 716 | /* Plugin object */ |
683 | static struct sched_plugin gsn_edf_plugin __cacheline_aligned_in_smp = { | 717 | static struct sched_plugin gsn_edf_plugin __cacheline_aligned_in_smp = { |
@@ -696,7 +730,8 @@ static struct sched_plugin gsn_edf_plugin __cacheline_aligned_in_smp = { | |||
696 | .inherit_priority = gsnedf_inherit_priority, | 730 | .inherit_priority = gsnedf_inherit_priority, |
697 | .return_priority = gsnedf_return_priority, | 731 | .return_priority = gsnedf_return_priority, |
698 | #endif | 732 | #endif |
699 | .admit_task = gsnedf_admit_task | 733 | .admit_task = gsnedf_admit_task, |
734 | .activate_plugin = gsnedf_activate_plugin, | ||
700 | }; | 735 | }; |
701 | 736 | ||
702 | 737 | ||
@@ -711,8 +746,6 @@ static int __init init_gsn_edf(void) | |||
711 | entry = &per_cpu(gsnedf_cpu_entries, cpu); | 746 | entry = &per_cpu(gsnedf_cpu_entries, cpu); |
712 | gsnedf_cpus[cpu] = entry; | 747 | gsnedf_cpus[cpu] = entry; |
713 | atomic_set(&entry->will_schedule, 0); | 748 | atomic_set(&entry->will_schedule, 0); |
714 | entry->linked = NULL; | ||
715 | entry->scheduled = NULL; | ||
716 | entry->cpu = cpu; | 749 | entry->cpu = cpu; |
717 | entry->hn = &gsnedf_heap_node[cpu]; | 750 | entry->hn = &gsnedf_heap_node[cpu]; |
718 | heap_node_init(&entry->hn, entry); | 751 | heap_node_init(&entry->hn, entry); |