diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html index 4c730524ab6..93a2e3b2ee9 100644 --- a/Documentation/NuttxPortingGuide.html +++ b/Documentation/NuttxPortingGuide.html @@ -12,7 +12,7 @@
Last Updated: March 8, 2009
+Last Updated: March 13, 2009
@@ -1629,9 +1629,13 @@ The system can be re-made subsequently by just typingmake.
CONFIG_PRIORITY_INHERITANCE: Set to enable support for
priority inheritance on mutexes and semaphores.
+ Priority inheritance is a strategy of addessing
+ priority inversion.
+ Details of the NuttX implementation of priority inheritance is
+ discussed elsewhere.
CONFIG_SEM_PREALLOCHOLDERS: : This setting is only used
+ CONFIG_SEM_PREALLOCHOLDERS: This setting is only used
if priority inheritance is enabled.
It defines the maximum number of different threads (minus one) that
can take counts on a semaphore with priority inheritance support.
@@ -1640,7 +1644,7 @@ The system can be re-made subsequently by just typing make.
than two threads participate using a counting semaphore.
CONFIG_SEM_NNESTPRIO. : If priority inheritance is enabled,
+ 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
diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html
index 5869beedf99..de3e370b871 100644
--- a/Documentation/NuttxUserGuide.html
+++ b/Documentation/NuttxUserGuide.html
@@ -13,7 +13,7 @@
User's Manual
by
Gregory Nutt
-
Last Updated: March 8, 2009
+Last Updated: March 13, 2009
@@ -1695,8 +1695,9 @@ interface of the same name. and, as a result, can adversely affect system response times.
- Priority Inversion. Proper use of semaphores avoids the issues of
- sched_lock(). However, consider the following example:
+ Priority Inversion.
+ Proper use of semaphores avoids the issues of sched_lock().
+ However, consider the following example:
+ Priority Inheritance.
+ As mentioned, NuttX does support priority inheritance provided that
+ CONFIG_PRIORITY_INHERITANCE is defined in your OS configuration file.
+ However, the implementation and configuration of the priority inheritance feature
+ is sufficiently complex that more needs to be said.
+ How can a feature that can be described by a single, simple sentence require such
+ a complex implementation:
+
CONFIG_SEM_PREALLOCHOLDERS.
+ First of all, in NuttX priority inheritance is implement on POSIX counting
+ semaphores. The reason for this is that these semaphores are the most
+ primitive waiting mechanism in NuttX; Most other waiting facilities are
+ based on semaphores. So if priority inheritance is implemented for POSIX
+ counting semaphores, then most NuttX waiting mechanisms will have this
+ capability.
+
+ Complexity arises because counting semaphores can have numerous
+ holders of semaphore counts. Therefore, in order to implement
+ priority inheritance across all holders, then internal data
+ structures must be allocated to manage the various holders associated
+ with a semaphore.
+ The setting CONFIG_SEM_PREALLOCHOLDERS defines the maximum
+ number of different threads (minus one per semaphore instance) that can
+ take counts on a semaphore with priority inheritance support.
+ This setting defines the size of a single pool of preallocated structures.
+ It may be set to zero if priority inheritance 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.
+
+ The cost associated with setting CONFIG_SEM_PREALLOCHOLDERS
+ is slightly increased code size and around 6-12 bytes times the value
+ of CONFIG_SEM_PREALLOCHOLDERS.
+
CONFIG_SEM_NNESTPRIO:
+ In addition, there may be multiple threads of various priorities that
+ need to wait for a count from the semaphore.
+ These, the lower priority thread holding the semaphore may have to
+ be boosted numerous time and, to make things more complex, will have
+ to keep track of all of the boost priorities values in in order to
+ correctly restore the priorities after a count has been handed out
+ to the higher priority thread.
+ The CONFIG_SEM_NNESTPRIO defines the size of an array,
+ one array per active thread.
+ 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 cost associated with setting CONFIG_SEM_NNESTPRIO
+ is slightly increased code size and (CONFIG_SEM_PREALLOCHOLDERS + 1)
+ times the maximum number of active threads.
+
sem_destroy()
+ then. Or what if the thread with the boosted priority reprioritizes itself?
+ The NuttX implement of priority inheritance attempts to handle all of these
+ types of corner cases, but it is very likely that some are missed.
+ The worst case result is that memory could by stranded within the priority
+ inheritance logic.
+ POSIX semaphore interfaces: