From 92d266b64e0def8554ebece70318a5ae0050573a Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Sat, 6 Apr 2013 13:56:22 -0400 Subject: Implement OMLP-Family budget exhaustion hooks. --- include/litmus/locking.h | 4 ++-- include/litmus/rt_param.h | 1 + litmus/budget.c | 7 +++++-- litmus/locking.c | 11 +++++++++++ litmus/sched_cedf.c | 2 -- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/litmus/locking.h b/include/litmus/locking.h index 08b06200b955..4dd8c66868e6 100644 --- a/include/litmus/locking.h +++ b/include/litmus/locking.h @@ -242,10 +242,10 @@ int wake_up_for_lock(struct task_struct* t); /* thread safe?? */ #ifndef CONFIG_LITMUS_NESTED_LOCKING -#define holds_locks(tsk) \ +#define holds_locks(t) \ (tsk_rt(t)->num_locks_held || tsk_rt(t)->num_local_locks_held) #else -#define holds_locks(tsk) \ +#define holds_locks(t) \ (tsk_rt(t)->num_locks_held || tsk_rt(t)->num_local_locks_held || !binheap_empty(&tsk_rt(t)->hp_blocked_tasks)) #endif diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h index 3f3aa240778f..a1cfdb6b6416 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h @@ -406,6 +406,7 @@ struct rt_param { /* pointer to lock upon which is currently blocked */ struct litmus_lock* blocked_lock; + struct litmus_lock* outermost_lock; #endif /* user controlled parameters */ diff --git a/litmus/budget.c b/litmus/budget.c index dd5f311c8b4a..4f692fd4a103 100644 --- a/litmus/budget.c +++ b/litmus/budget.c @@ -318,8 +318,11 @@ void sobliv_revaluate_task(struct task_struct* t) "CONFIG_LITMUS_NESTED_LOCKING enabled.\n"); #endif - /* TODO: If we hold an OMLP-family outmost lock, then we may - * need to move a task into a fifo queue */ + /* Move a waiter onto a FIFO queue to simulate an unlock call. */ + if (tsk_rt(t)->outermost_lock && + tsk_rt(t)->outermost_lock->ops->is_omlp_family) { + tsk_rt(t)->outermost_lock->ops->omlp_virtual_unlock(tsk_rt(t)->outermost_lock, t); + } } diff --git a/litmus/locking.c b/litmus/locking.c index d347fdce4cb7..88905d4cff26 100644 --- a/litmus/locking.c +++ b/litmus/locking.c @@ -125,6 +125,11 @@ asmlinkage long sys_litmus_lock(int lock_od) sched_trace_lock(current, l->ident, 1); TRACE_CUR("Got lock %d\n", l->ident); + + if (tsk_rt(current)->outermost_lock == NULL) { + TRACE_CUR("Lock %d is outermost lock.\n", l->ident); + tsk_rt(current)->outermost_lock = l; + } } } @@ -158,6 +163,12 @@ asmlinkage long sys_litmus_unlock(int lock_od) sched_trace_lock(current, l->ident, 0); TRACE_CUR("Unlocked %d\n", l->ident); + + if (tsk_rt(current)->outermost_lock == l) { + TRACE_CUR("Lock %d assumed to be outermost lock.\n", l->ident); + tsk_rt(current)->outermost_lock = NULL; + WARN_ON(holds_locks(current)); + } } } diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c index 1bfdef17e519..7178b6cd3ba1 100644 --- a/litmus/sched_cedf.c +++ b/litmus/sched_cedf.c @@ -803,9 +803,7 @@ static enum hrtimer_restart cedf_sobliv_on_exhausted(struct task_struct *t) } } } -#endif -#ifdef CONFIG_LITMUS_LOCKING /* Check our inheritance and propagate any changes forward. */ sobliv_revaluate_task(t); #endif -- cgit v1.2.2