diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-01-28 17:04:58 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-02-01 16:30:40 -0500 |
commit | e1b81e70c3af9d19d639bc8bdaa5a8fc13bf17a8 (patch) | |
tree | a05f415994b7313afff06a437e049c40bb5366cd /litmus/sched_psn_edf.c | |
parent | cc602187d4466374bca031039e145aa1b89aca96 (diff) |
SRP: port to new generic locking API
This re-enables SRP support under PSN-EDF and demonstrates how the new
locking API should be used.
Diffstat (limited to 'litmus/sched_psn_edf.c')
-rw-r--r-- | litmus/sched_psn_edf.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/litmus/sched_psn_edf.c b/litmus/sched_psn_edf.c index 01f31e407082..c1e27960576b 100644 --- a/litmus/sched_psn_edf.c +++ b/litmus/sched_psn_edf.c | |||
@@ -435,6 +435,45 @@ static long psnedf_return_priority(struct pi_semaphore *sem) | |||
435 | 435 | ||
436 | #endif | 436 | #endif |
437 | 437 | ||
438 | #ifdef CONFIG_LITMUS_LOCKING | ||
439 | |||
440 | #include <litmus/fdso.h> | ||
441 | #include <litmus/srp.h> | ||
442 | |||
443 | static unsigned int psnedf_get_srp_prio(struct task_struct* t) | ||
444 | { | ||
445 | /* assumes implicit deadlines */ | ||
446 | return get_rt_period(t); | ||
447 | } | ||
448 | |||
449 | static long psnedf_activate_plugin(void) | ||
450 | { | ||
451 | get_srp_prio = psnedf_get_srp_prio; | ||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | static long psnedf_allocate_lock(struct litmus_lock **lock, int type) | ||
456 | { | ||
457 | int err = -ENXIO; | ||
458 | struct srp_semaphore* srp; | ||
459 | |||
460 | switch (type) { | ||
461 | case SRP_SEM: | ||
462 | /* Baker's SRP */ | ||
463 | srp = allocate_srp_semaphore(); | ||
464 | if (srp) { | ||
465 | *lock = &srp->litmus_lock; | ||
466 | err = 0; | ||
467 | } else | ||
468 | err = -ENOMEM; | ||
469 | break; | ||
470 | }; | ||
471 | |||
472 | return err; | ||
473 | } | ||
474 | |||
475 | #endif | ||
476 | |||
438 | static long psnedf_admit_task(struct task_struct* tsk) | 477 | static long psnedf_admit_task(struct task_struct* tsk) |
439 | { | 478 | { |
440 | return task_cpu(tsk) == tsk->rt_param.task_params.cpu ? 0 : -EINVAL; | 479 | return task_cpu(tsk) == tsk->rt_param.task_params.cpu ? 0 : -EINVAL; |
@@ -450,7 +489,11 @@ static struct sched_plugin psn_edf_plugin __cacheline_aligned_in_smp = { | |||
450 | .schedule = psnedf_schedule, | 489 | .schedule = psnedf_schedule, |
451 | .task_wake_up = psnedf_task_wake_up, | 490 | .task_wake_up = psnedf_task_wake_up, |
452 | .task_block = psnedf_task_block, | 491 | .task_block = psnedf_task_block, |
453 | .admit_task = psnedf_admit_task | 492 | .admit_task = psnedf_admit_task, |
493 | #ifdef CONFIG_LITMUS_LOCKING | ||
494 | .allocate_lock = psnedf_allocate_lock, | ||
495 | .activate_plugin = psnedf_activate_plugin, | ||
496 | #endif | ||
454 | }; | 497 | }; |
455 | 498 | ||
456 | 499 | ||