diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html
index a381c6a6732..4c730524ab6 100644
--- a/Documentation/NuttxPortingGuide.html
+++ b/Documentation/NuttxPortingGuide.html
@@ -1639,6 +1639,13 @@ The system can be re-made subsequently by just typing make.
are only using semaphores as mutexes (only one holder) OR if no more
than two threads participate using a counting semaphore.
+
CONFIG_SEM_NNESTPRIO. : If priority inheritance is enabled,
+ then this setting is the maximum number of higher priority threads (minus
+ 1) than can be waiting for another thread to release a count on a semaphore.
+ This value may be set to zero if no more than one thread is expected to
+ wait for a semaphore.
+ diff --git a/configs/README.txt b/configs/README.txt index e6b656dc8c2..f6f12d4e423 100644 --- a/configs/README.txt +++ b/configs/README.txt @@ -207,6 +207,12 @@ defconfig -- This is a configuration file similar to the Linux are only using semaphores as mutexes (only one holder) OR if no more than two threads participate using a counting semaphore. + CONFIG_SEM_NNESTPRIO. If priority inheritance is enabled, + then this setting is the maximum number of higher priority + threads (minus 1) than can be waiting for another thread + to release a count on a semaphore. This value may be set + to zero if no more than one thread is expected to wait for + a semaphore. The following can be used to disable categories of APIs supported by the OS. If the compiler supports weak functions, then it diff --git a/configs/sim/ostest/defconfig b/configs/sim/ostest/defconfig index 32823d716df..ed95bb8a384 100644 --- a/configs/sim/ostest/defconfig +++ b/configs/sim/ostest/defconfig @@ -93,6 +93,11 @@ CONFIG_ARCH_BOARD_SIM=y # is disabled OR if you are only using semaphores as mutexes (only # one holder) OR if no more than two threads participate using a # counting semaphore. +# CONFIG_SEM_NNESTPRIO. If priority inheritance is enabled, then this +# setting is the maximum number of higher priority threads (minus 1) +# than can be waiting for another thread to release a count on a +# semaphore. This value may be set to zero if no more than one +# thread is expected to wait for a semaphore. # CONFIG_EXAMPLE=ostest CONFIG_DEBUG=y @@ -110,7 +115,8 @@ CONFIG_DEV_CONSOLE=y CONFIG_DEV_LOWCONSOLE=n CONFIG_MUTEX_TYPES=y CONFIG_PRIORITY_INHERITANCE=n -CONFIG_SEM_PREALLOCHOLDERS=3 +CONFIG_SEM_PREALLOCHOLDERS=0 +CONFIG_SEM_NNESTPRIO=0 # # The following can be used to disable categories of diff --git a/examples/ostest/prioinherit.c b/examples/ostest/prioinherit.c index 850c2fc3033..92238a8c243 100644 --- a/examples/ostest/prioinherit.c +++ b/examples/ostest/prioinherit.c @@ -60,7 +60,11 @@ # define CONFIG_SEM_PREALLOCHOLDERS 0 #endif #define NLOWPRI_THREADS (CONFIG_SEM_PREALLOCHOLDERS+1) -#define NHIGHPRI_THREADS 1 + +#ifndef CONFIG_SEM_NNESTPRIO +# define CONFIG_SEM_NNESTPRIO 0 +#endif +#define NHIGHPRI_THREADS (CONFIG_SEM_NNESTPRIO+1) /**************************************************************************** * Private Data diff --git a/sched/sem_holder.c b/sched/sem_holder.c index 3806bfdc9f1..21440752f0d 100644 --- a/sched/sem_holder.c +++ b/sched/sem_holder.c @@ -252,9 +252,6 @@ static int sem_boostholderprio(struct semholder_s *pholder, FAR sem_t *sem, FAR { FAR _TCB *htcb = (FAR _TCB *)pholder->holder; FAR _TCB *rtcb = (FAR _TCB*)arg; -#if CONFIG_SEM_NNESTPRIO > 0 - int i; -#endif /* Make sure that the thread is still active. If it exited without releasing * its counts, then that would be a bad thing. But we can take no real @@ -301,7 +298,7 @@ static int sem_boostholderprio(struct semholder_s *pholder, FAR sem_t *sem, FAR } else { - sdgb("CONFIG_SEM_NNESTPRIO exceeded\n"); + sdbg("CONFIG_SEM_NNESTPRIO exceeded\n"); } } @@ -358,7 +355,7 @@ static int sem_verifyholder(struct semholder_s *pholder, FAR sem_t *sem, FAR voi FAR _TCB *htcb = (FAR _TCB *)pholder->holder; #if CONFIG_SEM_NNESTPRIO > 0 - DEBUGASSERT(htcb->npend_repri == 0); + DEBUGASSERT(htcb->npend_reprio == 0); #endif DEBUGASSERT(htcb->sched_priority == htcb->base_priority); return 0; @@ -404,7 +401,7 @@ static int sem_restoreholderprio(struct semholder_s *pholder, FAR sem_t *sem, FA { /* No... the thread has only been boosted once */ - DEBUGASSERT(hctb->sched_priority == stcb->sched_priority && npend_reprio == 0); + DEBUGASSERT(htcb->sched_priority == stcb->sched_priority && htcb->npend_reprio == 0); rpriority = htcb->base_priority; }