From 30ec11d932ed9317035d0e56c550ac1353911792 Mon Sep 17 00:00:00 2001 From: Jeremy Erickson Date: Fri, 3 May 2013 17:35:35 -0400 Subject: Add some debugging, correctness, and style improvements --- litmus/sched_edf_os.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/litmus/sched_edf_os.c b/litmus/sched_edf_os.c index ba049adc8154..a4b3cdeb1a07 100644 --- a/litmus/sched_edf_os.c +++ b/litmus/sched_edf_os.c @@ -287,10 +287,10 @@ static int next_cpu_for_job(struct task_struct *t) /* Process any new subtask releases. */ node = bheap_peek(fakepfair_ready_order, &edfos_params(t).release_queue); - while (node && *((int*)node->value) <= tsk_rt(t)->job_params.job_no) - { + while (node && *((int*)node->value) <= tsk_rt(t)->job_params.job_no) { node = bheap_take(fakepfair_ready_order, &edfos_params(t).release_queue); + BUG_ON(!node); cpu = ((int*)node->value) - edfos_params(t).heap_data; *((int*)node->value) = compute_pfair_deadline( edfos_params(t).fraction[cpu][0], @@ -305,6 +305,7 @@ static int next_cpu_for_job(struct task_struct *t) /* Choose the next Pfair subtask. */ node = bheap_take(fakepfair_ready_order, &edfos_params(t).ready_queue); + BUG_ON(!node); cpu = ((int*)node->value) - edfos_params(t).heap_data; next_rel = compute_pfair_release(edfos_params(t).fraction[cpu][0], @@ -314,7 +315,7 @@ static int next_cpu_for_job(struct task_struct *t) if (next_rel <= tsk_rt(t)->job_params.job_no) { /* Next subtask already released. */ - (*(int*)node->value) = compute_pfair_deadline( + *((int*)node->value) = compute_pfair_deadline( edfos_params(t).fraction[cpu][0], edfos_params(t).fraction[cpu][1], tsk_rt(t)->semi_part.cpu_job_no[cpu] + @@ -325,7 +326,7 @@ static int next_cpu_for_job(struct task_struct *t) else { /* Next subtask not yet released. */ - (*(int*)node->value) = next_rel; + *((int*)node->value) = next_rel; bheap_insert(fakepfair_ready_order, &edfos_params(t).release_queue, node); } @@ -349,6 +350,7 @@ static void change_migrat_cpu_if_needed(struct task_struct *t) * and the next release */ cpu = next_cpu_for_job(t); + BUG(); if (unlikely(cpu != get_partition(t))) { tsk_rt(t)->task_params.cpu = cpu; TRACE_TASK(t, "EDF-os: will migrate job %d -> %d\n", @@ -482,21 +484,28 @@ static void edfos_task_new(struct task_struct * t, int on_rq, int running) edfos_domain_t* edfos = task_edfos(t); unsigned long flags; unsigned int i; + unsigned int has_cpu = 0; - for (i = 0; i < NR_CPUS; i++) - { - if (edfos_params(t).fraction[i][0] > 0) - { - edfos_params(t).heap_data[i] = compute_pfair_deadline( + if (edfos_params(t).migrat) { + bheap_init(&edfos_params(t).release_queue); + bheap_init(&edfos_params(t).ready_queue); + for (i = 0; i < NR_CPUS; i++) { + if (edfos_params(t).fraction[i][0] > 0) { + has_cpu = 1; + edfos_params(t).heap_data[i] = + compute_pfair_deadline( edfos_params(t).fraction[i][0], edfos_params(t).fraction[i][1], 0); - bheap_add(fakepfair_ready_order, - &edfos_params(t).ready_queue, - &edfos_params(t).heap_data[i], GFP_ATOMIC); + bheap_add(fakepfair_ready_order, + &edfos_params(t).ready_queue, + &edfos_params(t).heap_data[i], + GFP_ATOMIC); + } } + BUG_ON(!has_cpu); + /* Pick the first CPU to execute on. */ + change_migrat_cpu_if_needed(t); } - /* Pick the first CPU to execute on. */ - change_migrat_cpu_if_needed(t); TRACE_TASK(t, "EDF-os: task new, cpu = %d\n", t->rt_param.task_params.cpu); -- cgit v1.2.2