kernel/sched: disable priority inheritance on all signaling semaphores
authorHeesub Shin <heesub.shin@samsung.com>
Thu, 6 Apr 2017 02:02:50 +0000 (11:02 +0900)
committerHeesub Shin <heesub.shin@samsung.com>
Tue, 18 Apr 2017 03:02:11 +0000 (12:02 +0900)
Disable priority inheritance on all semaphores used for signaling.

Change-Id: Iaaac2a321fb127e76d01c1eadf625f47134181b0
Signed-off-by: Gregory Nutt <gnutt@nuttx.org>
[Shin: backported 1da3a5f from NuttX]
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
os/include/tinyara/semaphore.h
os/kernel/pthread/pthread_create.c

index 733a286..f5db2a9 100644 (file)
@@ -207,7 +207,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
index a5a6159..ffea3dc 100644 (file)
 #include <errno.h>
 #include <queue.h>
 
+#include <tinyara/arch.h>
+#include <tinyara/semaphore.h>
 #include <tinyara/kmalloc.h>
 #include <tinyara/pthread.h>
-#include <tinyara/arch.h>
 
 #include "sched/sched.h"
 #include "group/group.h"
@@ -401,6 +402,18 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, pthrea
                ret = sem_init(&pjoin->exit_sem, 0, 0);
        }
 
+       /*
+        * These semapohres 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);
+       }
+
        /* Activate the task */
 
        sched_lock();