diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2010-07-12 15:37:11 -0400 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2010-08-03 12:43:47 -0400 |
commit | ecba65ae9c3cdab3a98db0633b0422e4967d3544 (patch) | |
tree | b952797010440706833fa76ed4ff33f122eb0581 | |
parent | ad65f33069df4eb9425470e3557fbf976d967e52 (diff) |
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
<protocol_name>_<callback>. Ex: <fmlp>_<inherit_priority>
-rw-r--r-- | litmus/litmus.c | 19 | ||||
-rw-r--r-- | 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 @@ | |||
21 | 21 | ||
22 | #include <litmus/rt_domain.h> | 22 | #include <litmus/rt_domain.h> |
23 | 23 | ||
24 | #ifdef CONFIG_PI_SEMAPHORES | ||
25 | #include <litmus/prio_sem.h> | ||
26 | #endif | ||
27 | |||
24 | /* Number of RT tasks that exist in the system */ | 28 | /* Number of RT tasks that exist in the system */ |
25 | atomic_t rt_task_count = ATOMIC_INIT(0); | 29 | atomic_t rt_task_count = ATOMIC_INIT(0); |
26 | static DEFINE_RAW_SPINLOCK(task_transition_lock); | 30 | static DEFINE_RAW_SPINLOCK(task_transition_lock); |
@@ -288,10 +292,13 @@ static void reinit_litmus_state(struct task_struct* p, int restore) | |||
288 | ctrl_page = p->rt_param.ctrl_page; | 292 | ctrl_page = p->rt_param.ctrl_page; |
289 | } | 293 | } |
290 | 294 | ||
295 | #ifdef CONFIG_PI_SEMAPHORES | ||
291 | /* We probably should not be inheriting any task's priority | 296 | /* We probably should not be inheriting any task's priority |
292 | * at this point in time. | 297 | * at this point in time. |
293 | */ | 298 | */ |
294 | WARN_ON(p->rt_param.inh_task); | 299 | WARN_ON(has_pi_sem(p)); |
300 | WARN_ON(p->rt_param.eff_priority); | ||
301 | #endif | ||
295 | 302 | ||
296 | /* We need to restore the priority of the task. */ | 303 | /* We need to restore the priority of the task. */ |
297 | // __setscheduler(p, p->rt_param.old_policy, p->rt_param.old_prio); XXX why is this commented? | 304 | // __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) | |||
331 | 338 | ||
332 | INIT_LIST_HEAD(&tsk_rt(tsk)->list); | 339 | INIT_LIST_HEAD(&tsk_rt(tsk)->list); |
333 | 340 | ||
341 | #ifdef CONFIG_PI_SEMAPHORES | ||
342 | INIT_LIST_HEAD(&tsk_rt(tsk)->pi_sem_stack); | ||
343 | tsk_rt(tsk)->eff_priority = NULL; | ||
344 | #endif | ||
345 | |||
334 | /* avoid scheduler plugin changing underneath us */ | 346 | /* avoid scheduler plugin changing underneath us */ |
335 | raw_spin_lock_irqsave(&task_transition_lock, flags); | 347 | raw_spin_lock_irqsave(&task_transition_lock, flags); |
336 | 348 | ||
@@ -453,7 +465,10 @@ void litmus_exec(void) | |||
453 | struct task_struct* p = current; | 465 | struct task_struct* p = current; |
454 | 466 | ||
455 | if (is_realtime(p)) { | 467 | if (is_realtime(p)) { |
456 | WARN_ON(p->rt_param.inh_task); | 468 | #ifdef CONFIG_PI_SEMAPHORES |
469 | WARN_ON(has_pi_sem(p)); | ||
470 | WARN_ON(p->rt_param.eff_priority); | ||
471 | #endif | ||
457 | if (tsk_rt(p)->ctrl_page) { | 472 | if (tsk_rt(p)->ctrl_page) { |
458 | free_page((unsigned long) tsk_rt(p)->ctrl_page); | 473 | free_page((unsigned long) tsk_rt(p)->ctrl_page); |
459 | tsk_rt(p)->ctrl_page = NULL; | 474 | 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) | |||
125 | return 0; | 125 | return 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | #ifdef CONFIG_FMLP | 128 | #ifdef CONFIG_PI_SEMAPHORES |
129 | 129 | ||
130 | static long litmus_dummy_inherit_priority(struct pi_semaphore *sem, | 130 | static long litmus_dummy_inherit_priority(struct pi_semaphore *sem, |
131 | struct task_struct *new_owner) | 131 | struct task_struct *new_owner) |
@@ -163,9 +163,9 @@ struct sched_plugin linux_sched_plugin = { | |||
163 | .activate_plugin = litmus_dummy_activate_plugin, | 163 | .activate_plugin = litmus_dummy_activate_plugin, |
164 | .deactivate_plugin = litmus_dummy_deactivate_plugin, | 164 | .deactivate_plugin = litmus_dummy_deactivate_plugin, |
165 | #ifdef CONFIG_FMLP | 165 | #ifdef CONFIG_FMLP |
166 | .inherit_priority = litmus_dummy_inherit_priority, | 166 | .fmlp_inherit_priority = litmus_dummy_inherit_priority, |
167 | .return_priority = litmus_dummy_return_priority, | 167 | .fmlp_return_priority = litmus_dummy_return_priority, |
168 | .pi_block = litmus_dummy_pi_block, | 168 | .fmlp_pi_block = litmus_dummy_pi_block, |
169 | #endif | 169 | #endif |
170 | .admit_task = litmus_dummy_admit_task | 170 | .admit_task = litmus_dummy_admit_task |
171 | }; | 171 | }; |
@@ -193,6 +193,10 @@ static DEFINE_RAW_SPINLOCK(sched_plugins_lock); | |||
193 | if (!plugin->func) \ | 193 | if (!plugin->func) \ |
194 | plugin->func = litmus_dummy_ ## func;} | 194 | plugin->func = litmus_dummy_ ## func;} |
195 | 195 | ||
196 | #define CHECK_PI(type, func) {\ | ||
197 | if (!plugin->type ## _ ## func) \ | ||
198 | plugin->type ## _ ## func = litmus_dummy_ ## func; } | ||
199 | |||
196 | /* FIXME: get reference to module */ | 200 | /* FIXME: get reference to module */ |
197 | int register_sched_plugin(struct sched_plugin* plugin) | 201 | int register_sched_plugin(struct sched_plugin* plugin) |
198 | { | 202 | { |
@@ -211,9 +215,9 @@ int register_sched_plugin(struct sched_plugin* plugin) | |||
211 | CHECK(activate_plugin); | 215 | CHECK(activate_plugin); |
212 | CHECK(deactivate_plugin); | 216 | CHECK(deactivate_plugin); |
213 | #ifdef CONFIG_FMLP | 217 | #ifdef CONFIG_FMLP |
214 | CHECK(inherit_priority); | 218 | CHECK_PI(fmlp, inherit_priority); |
215 | CHECK(return_priority); | 219 | CHECK_PI(fmlp, return_priority); |
216 | CHECK(pi_block); | 220 | CHECK_PI(fmlp, pi_block); |
217 | #endif | 221 | #endif |
218 | CHECK(admit_task); | 222 | CHECK(admit_task); |
219 | 223 | ||