diff --git a/include/nuttx/semaphore.h b/include/nuttx/semaphore.h index 04fde1bacbd..1b90a1b6a0d 100644 --- a/include/nuttx/semaphore.h +++ b/include/nuttx/semaphore.h @@ -205,7 +205,7 @@ int sem_getprotocol(FAR sem_t *sem, FAR int *protocol); #ifdef CONFIG_PRIORITY_INHERITANCE int sem_setprotocol(FAR sem_t *sem, int protocol); #else -# define sem_setprotocol(s,p) DEBUGASSERT((p) == SEM_PRIO_NONE); +# define sem_setprotocol(s,p) ((p) == SEM_PRIO_NONE ? 0 : -ENOSYS); #endif #undef EXTERN diff --git a/sched/group/group_create.c b/sched/group/group_create.c index 2aecb9c12b4..d5cee380029 100644 --- a/sched/group/group_create.c +++ b/sched/group/group_create.c @@ -46,6 +46,7 @@ #include #include +#include #include "environ/environ.h" #include "group/group.h" @@ -248,9 +249,14 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype) #endif #if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_SCHED_HAVE_PARENT) - /* Initialize the exit/wait semaphores */ + /* Initialize the exit/wait semaphores + * + * This semaphore is used for signaling and, hence, should not have + * priority inheritance enabled. + */ (void)sem_init(&group->tg_exitsem, 0, 0); + (void)sem_setprotocol(&group->tg_exitsem, SEM_PRIO_NONE); #endif return OK; diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index be81a5f0fff..dccee1b9652 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -49,9 +49,10 @@ #include #include +#include +#include #include #include -#include #include "sched/sched.h" #include "group/group.h" @@ -498,6 +499,20 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, ret = sem_init(&pjoin->exit_sem, 0, 0); } + /* Thse semaphores are used for signaling and, hence, should not have + * priority inheritance enabled. + */ + + if (ret == OK) + { + ret = sem_setprotocol(&pjoin->data_sem, SEM_PRIO_NONE); + } + + if (ret == OK) + { + ret = sem_setprotocol(&pjoin->exit_sem, SEM_PRIO_NONE); + } + /* If the priority of the new pthread is lower than the priority of the * parent thread, then starting the pthread could result in both the * parent and the pthread to be blocked. This is a recipe for priority