Going more forward from POSIX pthread mutex protocol description: The protocol attribute defines the protocol to be followed in utilizing mutexes. The value of protocol may be one of: - PTHREAD_PRIO_INHERIT - PTHREAD_PRIO_NONE - PTHREAD_PRIO_PROTECT which are defined in the <pthread.h> header. The default value of the attribute shall be PTHREAD_PRIO_NONE.
So it is reasonable to change default behavior for semaphores in order to restore POSIX compliance for pthread mutexes as well. Best regards, Petro On Wed, Jan 5, 2022, 8:17 PM Petro Karashchenko < petro.karashche...@gmail.com> wrote: > Hi team, > > Sorry I probably missed some part of discussion. So it was decided to keep > priority inheritance ON for counting semaphores by default if the feature > is enabled? And we are modifying all the POSIX by adding explicit setting > to SEM_PRIO_NONE? > > I truly believe that priority inheritance on counting semaphores should be > explicitly enabled (disabled by default) and enabling it by default might > lead to unexpected priority boost for low priority tasks that violates > real-time requirements. > > The https://github.com/apache/incubator-nuttx/pull/5070 is definitely one > of the possible solutions and we can continue with it or decide to go > without TCB size increase and add pid into semholder struct + > "(pholder->htcb == nxsched_get_tcb(pholder->pid))" check to ensure that > htcb still points to original task that became a holder. > > Best regards, > Petro > > On Wed, Jan 5, 2022, 1:54 PM Xiang Xiao <xiaoxiang781...@gmail.com> wrote: > >> Here are the two patch which demo that POSIX compliant code crash directly >> when CONFIG_PRIORITY_INHERITANCE is enabled: >> https://github.com/apache/incubator-nuttx/pull/5170 >> https://github.com/apache/incubator-nuttx-apps/pull/960 >> Please give your more feedback at >> https://github.com/apache/incubator-nuttx/pull/5070. >> If there is no more concern, we will start the full modification in the >> next week. >> >> Thanks >> Xiang >> >> >> >> On Sat, Dec 25, 2021 at 5:47 AM Gregory Nutt <spudan...@gmail.com> wrote: >> >> > > Please help review this PR for correctness and standards compliance, >> > > keeping in mind the Inviolable principles of NuttX [2], particularly >> > > the section on POSIX compliance: >> > > >> > >> > I don't think POSIX addresses priority inheritance on counting >> semaphores. >> > POSIX only addresses priority inheritance on pthread mutexes. I need to >> > double check that. >> > >> > Priority inheritance on counting semaphores is a natural extension and >> > certainly required for a well-behaved embedded system. But I don't >> think >> > there is a good spec-based argument, is there? >> > >> >