From dbade675fdd1f84f620d0cda54caf0f23953733c Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 13 Mar 2009 00:54:10 +0000 Subject: Add test for CONFIG_SEM_PREALLOCHOLDERS > 0 git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1597 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/Documentation/NuttxPortingGuide.html | 7 +++++++ nuttx/configs/README.txt | 6 ++++++ nuttx/configs/sim/ostest/defconfig | 8 +++++++- nuttx/examples/ostest/prioinherit.c | 6 +++++- nuttx/sched/sem_holder.c | 9 +++------ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index a381c6a67..4c730524a 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/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/nuttx/configs/README.txt b/nuttx/configs/README.txt index e6b656dc8..f6f12d4e4 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/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/nuttx/configs/sim/ostest/defconfig b/nuttx/configs/sim/ostest/defconfig index 32823d716..ed95bb8a3 100644 --- a/nuttx/configs/sim/ostest/defconfig +++ b/nuttx/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/nuttx/examples/ostest/prioinherit.c b/nuttx/examples/ostest/prioinherit.c index 850c2fc30..92238a8c2 100644 --- a/nuttx/examples/ostest/prioinherit.c +++ b/nuttx/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/nuttx/sched/sem_holder.c b/nuttx/sched/sem_holder.c index 3806bfdc9..21440752f 100644 --- a/nuttx/sched/sem_holder.c +++ b/nuttx/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; } -- cgit v1.2.3