From ecba65ae9c3cdab3a98db0633b0422e4967d3544 Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Mon, 12 Jul 2010 15:37:11 -0400 Subject: Updated plugin interface to support pi_semaphore. This patch continues the implementation of a generic pi framework. Patches 7ef1e106db5a061682028fdc4d8ffd131729868a and fb158820bb9441a08bc932aab30dda5d77319cb5 restructured pi_semaphore and implemented a semaphore stack, respectively. This patch updates the parts common to all scheduler plugins-- namely, task struct initialization and default semaphore operation callbacks (ex. inherit_priority). Also added a macro to aid in callback validation of functions of the form _. Ex: _ --- litmus/litmus.c | 19 +++++++++++++++++-- litmus/sched_plugin.c | 18 +++++++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/litmus/litmus.c b/litmus/litmus.c index c60423228607..0192f6a8c0fb 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c @@ -21,6 +21,10 @@ #include +#ifdef CONFIG_PI_SEMAPHORES +#include +#endif + /* Number of RT tasks that exist in the system */ atomic_t rt_task_count = ATOMIC_INIT(0); static DEFINE_RAW_SPINLOCK(task_transition_lock); @@ -288,10 +292,13 @@ static void reinit_litmus_state(struct task_struct* p, int restore) ctrl_page = p->rt_param.ctrl_page; } +#ifdef CONFIG_PI_SEMAPHORES /* We probably should not be inheriting any task's priority * at this point in time. */ - WARN_ON(p->rt_param.inh_task); + WARN_ON(has_pi_sem(p)); + WARN_ON(p->rt_param.eff_priority); +#endif /* We need to restore the priority of the task. */ // __setscheduler(p, p->rt_param.old_policy, p->rt_param.old_prio); XXX why is this commented? @@ -331,6 +338,11 @@ long litmus_admit_task(struct task_struct* tsk) INIT_LIST_HEAD(&tsk_rt(tsk)->list); +#ifdef CONFIG_PI_SEMAPHORES + INIT_LIST_HEAD(&tsk_rt(tsk)->pi_sem_stack); + tsk_rt(tsk)->eff_priority = NULL; +#endif + /* avoid scheduler plugin changing underneath us */ raw_spin_lock_irqsave(&task_transition_lock, flags); @@ -453,7 +465,10 @@ void litmus_exec(void) struct task_struct* p = current; if (is_realtime(p)) { - WARN_ON(p->rt_param.inh_task); +#ifdef CONFIG_PI_SEMAPHORES + WARN_ON(has_pi_sem(p)); + WARN_ON(p->rt_param.eff_priority); +#endif if (tsk_rt(p)->ctrl_page) { free_page((unsigned long) tsk_rt(p)->ctrl_page); tsk_rt(p)->ctrl_page = NULL; diff --git a/litmus/sched_plugin.c b/litmus/sched_plugin.c index 3543b7baff53..0ebb677198d5 100644 --- a/litmus/sched_plugin.c +++ b/litmus/sched_plugin.c @@ -125,7 +125,7 @@ static long litmus_dummy_deactivate_plugin(void) return 0; } -#ifdef CONFIG_FMLP +#ifdef CONFIG_PI_SEMAPHORES static long litmus_dummy_inherit_priority(struct pi_semaphore *sem, struct task_struct *new_owner) @@ -163,9 +163,9 @@ struct sched_plugin linux_sched_plugin = { .activate_plugin = litmus_dummy_activate_plugin, .deactivate_plugin = litmus_dummy_deactivate_plugin, #ifdef CONFIG_FMLP - .inherit_priority = litmus_dummy_inherit_priority, - .return_priority = litmus_dummy_return_priority, - .pi_block = litmus_dummy_pi_block, + .fmlp_inherit_priority = litmus_dummy_inherit_priority, + .fmlp_return_priority = litmus_dummy_return_priority, + .fmlp_pi_block = litmus_dummy_pi_block, #endif .admit_task = litmus_dummy_admit_task }; @@ -193,6 +193,10 @@ static DEFINE_RAW_SPINLOCK(sched_plugins_lock); if (!plugin->func) \ plugin->func = litmus_dummy_ ## func;} +#define CHECK_PI(type, func) {\ + if (!plugin->type ## _ ## func) \ + plugin->type ## _ ## func = litmus_dummy_ ## func; } + /* FIXME: get reference to module */ int register_sched_plugin(struct sched_plugin* plugin) { @@ -211,9 +215,9 @@ int register_sched_plugin(struct sched_plugin* plugin) CHECK(activate_plugin); CHECK(deactivate_plugin); #ifdef CONFIG_FMLP - CHECK(inherit_priority); - CHECK(return_priority); - CHECK(pi_block); + CHECK_PI(fmlp, inherit_priority); + CHECK_PI(fmlp, return_priority); + CHECK_PI(fmlp, pi_block); #endif CHECK(admit_task); -- cgit v1.2.2