From 075fd6aa34f6f5dcc535bcc674ce43fb1b50b40f Mon Sep 17 00:00:00 2001 From: Jeremy Erickson Date: Fri, 10 May 2013 18:22:39 -0400 Subject: Lookup table EDF-os --- include/litmus/rt_param.h | 8 +++++--- litmus/litmus.c | 15 ++++++++++++++- litmus/sched_edf_os.c | 45 +++++++++++++++++++++++++-------------------- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h index bc3bbd07ef26..9208b0eeffef 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h @@ -67,17 +67,18 @@ struct edfos_params { unsigned int first_cpu; /* Whether this task is a migrating task*/ unsigned int migrat; + unsigned int* lookup_table; /* Time of next subtask release or deadline */ - int heap_data[NR_CPUS_EDF_OS]; + /*int heap_data[NR_CPUS_EDF_OS];*/ /* Fraction of this task exec_cost that each CPU should handle. * We keep the fraction divided in num/denom : a matrix of * (NR_CPUS_EDF_OS rows) x (2 columns). * The first column is the numerator of the fraction. * The second column is the denominator. */ - lt_t fraction[NR_CPUS_EDF_OS][2]; + /*lt_t fraction[NR_CPUS_EDF_OS][2]; struct bheap release_queue; - struct bheap ready_queue; + struct bheap ready_queue;*/ }; /* Parameters for NPS-F semi-partitioned scheduling algorithm. @@ -128,6 +129,7 @@ struct rt_task { unsigned int cpu; task_class_t cls; budget_policy_t budget_policy; /* ignored by pfair */ + unsigned int lookup_len; /* Only used by EDF-os. */ /* parameters used by the semi-partitioned algorithms */ union { diff --git a/litmus/litmus.c b/litmus/litmus.c index 2f780222d8e8..debfc45bb8e6 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c @@ -75,6 +75,7 @@ asmlinkage long sys_set_rt_task_param(pid_t pid, struct rt_task __user * param) { struct rt_task tp; struct task_struct *target; + int * lookup_table; int retval = -EINVAL; printk("Setting up rt task parameters for process %d.\n", pid); @@ -124,7 +125,19 @@ asmlinkage long sys_set_rt_task_param(pid_t pid, struct rt_task __user * param) pid, tp.budget_policy); goto out_unlock; } - + if (tp.lookup_len > 0) { + lookup_table = kmalloc(tp.lookup_len * sizeof(unsigned int), + GFP_KERNEL); + if (!lookup_table) + goto out_unlock; + if (copy_from_user(lookup_table, tp.lookup_table, tp.lookup_len + * sizeof(lookup_table))) { + retval = -EFAULT; + kfree(lookup_table); + goto out_unlock; + } + tp.lookup_table = lookup_table; + } target->rt_param.task_params = tp; retval = 0; diff --git a/litmus/sched_edf_os.c b/litmus/sched_edf_os.c index e021d22b5129..82e42593f764 100644 --- a/litmus/sched_edf_os.c +++ b/litmus/sched_edf_os.c @@ -82,10 +82,10 @@ int edfos_ready_order(struct bheap_node* a, struct bheap_node* b) return edfos_higher_prio(bheap2task(a), bheap2task(b)); } -static int fakepfair_ready_order(struct bheap_node* a, struct bheap_node* b) +/*static int fakepfair_ready_order(struct bheap_node* a, struct bheap_node* b) { return *((int*)a->value) < *((int*)b->value); -} +}*/ /* need_to_preempt - check whether the task t needs to be preempted * call only with irqs disabled and with ready_lock acquired @@ -279,13 +279,16 @@ static int compute_pfair_release(lt_t wt_num, lt_t wt_den, static int next_cpu_for_job(struct task_struct *t) { - unsigned int cpu; + return edfos_params(t).lookup_table[tsk_rt(t)->job_params.job_no % + tsk_rt(t)->task_params.lookup_len]; + + /*unsigned int cpu; lt_t next_rel; struct bheap_node* node; - BUG_ON(!is_migrat_task(t)); + BUG_ON(!is_migrat_task(t));*/ /* Process any new subtask releases. */ - node = bheap_peek(fakepfair_ready_order, + /*node = bheap_peek(fakepfair_ready_order, &edfos_params(t).release_queue); while (node && *((int*)node->value) <= tsk_rt(t)->job_params.job_no) { node = bheap_take(fakepfair_ready_order, @@ -300,10 +303,10 @@ static int next_cpu_for_job(struct task_struct *t) &edfos_params(t).ready_queue, node); node = bheap_peek(fakepfair_ready_order, &edfos_params(t).release_queue); - } + }*/ /* Choose the next Pfair subtask. */ - node = bheap_take(fakepfair_ready_order, + /*node = bheap_take(fakepfair_ready_order, &edfos_params(t).ready_queue); BUG_ON(!node); cpu = ((int*)node->value) - edfos_params(t).heap_data; @@ -313,9 +316,9 @@ static int next_cpu_for_job(struct task_struct *t) tsk_rt(t)->semi_part.cpu_job_no[cpu] + 1); 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] + @@ -324,9 +327,9 @@ static int next_cpu_for_job(struct task_struct *t) &edfos_params(t).ready_queue, node); } 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); } @@ -334,7 +337,7 @@ static int next_cpu_for_job(struct task_struct *t) TRACE_TASK(t, "%u = %u * %u / %u\n", t->rt_param.job_params.job_no, cur_cpu_job_no(t), cur_cpu_fract_den(t), cur_cpu_fract_num(t)); - return cpu; + return cpu;*/ } /* If needed (the share for task t on this CPU is exhausted), updates @@ -484,13 +487,13 @@ static void edfos_task_new(struct task_struct * t, int on_rq, int running) unsigned long flags; unsigned int i; - if (edfos_params(t).migrat) { +/* 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_EDF_OS; i++) { - if (i == t->rt_param.task_params.cpu) { + if (i == t->rt_param.task_params.cpu) {*/ /* Initial CPU - setup next release. */ - edfos_params(t).heap_data[i] = +/* edfos_params(t).heap_data[i] = compute_pfair_release( edfos_params(t).fraction[i][0], edfos_params(t).fraction[i][1], 2); @@ -499,11 +502,11 @@ static void edfos_task_new(struct task_struct * t, int on_rq, int running) &edfos_params(t).heap_data[i], GFP_ATOMIC); } - else if (edfos_params(t).fraction[i][0] > 0) { + else if (edfos_params(t).fraction[i][0] > 0) {*/ /* Non-initial CPU - already released, setup * deadline. */ - edfos_params(t).heap_data[i] = +/* edfos_params(t).heap_data[i] = compute_pfair_deadline( edfos_params(t).fraction[i][0], edfos_params(t).fraction[i][1], 1); @@ -513,7 +516,7 @@ static void edfos_task_new(struct task_struct * t, int on_rq, int running) GFP_ATOMIC); } } - } + }*/ TRACE_TASK(t, "EDF-os: task new, cpu = %d\n", t->rt_param.task_params.cpu); @@ -610,10 +613,12 @@ static void edfos_task_exit(struct task_struct * t) edfos->scheduled = NULL; /* Deallocate heap nodes. */ - while (bheap_take_del(fakepfair_ready_order, +/* while (bheap_take_del(fakepfair_ready_order, &edfos_params(t).release_queue)) {} while (bheap_take_del(fakepfair_ready_order, - &edfos_params(t).ready_queue)) {} + &edfos_params(t).ready_queue)) {}*/ + if (tsk_rt(t)->task_params.lookup_len) + kfree(edfos_params(t).lookup_table); TRACE_TASK(t, "RIP\n"); -- cgit v1.2.2