From 53c51e08ddc1b83bedb890338142ce9a6ba289be Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Jun 2013 16:49:41 -0600 Subject: Fix an assertion --- nuttx/sched/sem_holder.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'nuttx/sched') diff --git a/nuttx/sched/sem_holder.c b/nuttx/sched/sem_holder.c index ab59ec8c8..b88bebf36 100644 --- a/nuttx/sched/sem_holder.c +++ b/nuttx/sched/sem_holder.c @@ -448,11 +448,22 @@ static int sem_restoreholderprio(FAR struct semholder_s *pholder, FAR sem_t *sem if (htcb->npend_reprio < 1) { - /* No... the holder thread has only been boosted once. Reset all - * priorities back to the base priority. + /* No... the holder thread has only been boosted once. + * npend_reprio should be 0 and the boosted priority should be the + * priority of the task that just got the semaphore + * (stcb->sched_priority) + * + * That latter assumption may not be true if the stcb's priority + * was also boosted so that it no longer matches the htcb's + * sched_priority. Or if CONFIG_SEM_NNESTPRIO is too small (so + * that we do not have a proper record of the reprioritizations). */ - DEBUGASSERT(htcb->sched_priority == stcb->sched_priority && htcb->npend_reprio == 0); + DEBUGASSERT(/* htcb->sched_priority == stcb->sched_priority && */ + htcb->npend_reprio == 0); + + /* Reset the holder's priority back to the base priority. */ + sched_reprioritize(htcb, htcb->base_priority); } -- cgit v1.2.3