sem_setprotocol: Handle a case of missing proxy for sem_setprotocol. Reorder so that (1) this error is avoided, and (2) >No proxy is needed if priority inheritance is not enabled.

This commit is contained in:
Gregory Nutt
2016-11-03 18:51:38 -06:00
parent 6ff6cca1a0
commit 73fc186beb
5 changed files with 125 additions and 7 deletions
+2 -2
View File
@@ -37,10 +37,10 @@
CSRCS += sem_destroy.c sem_wait.c sem_trywait.c sem_tickwait.c
CSRCS += sem_timedwait.c sem_timeout.c sem_post.c sem_recover.c
CSRCS += sem_reset.c sem_setprotocol.c sem_waitirq.c
CSRCS += sem_reset.c sem_waitirq.c
ifeq ($(CONFIG_PRIORITY_INHERITANCE),y)
CSRCS += sem_initialize.c sem_holder.c
CSRCS += sem_initialize.c sem_holder.c sem_setprotocol.c
endif
ifeq ($(CONFIG_SPINLOCK),y)
+4 -4
View File
@@ -46,6 +46,8 @@
#include "semaphore/semaphore.h"
#ifdef CONFIG_PRIORITY_INHERITANCE
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -95,7 +97,6 @@ int sem_setprotocol(FAR sem_t *sem, int protocol)
switch (protocol)
{
case SEM_PRIO_NONE:
#ifdef CONFIG_PRIORITY_INHERITANCE
/* Disable priority inheritance */
sem->flags |= PRIOINHERIT_FLAGS_DISABLE;
@@ -103,16 +104,13 @@ int sem_setprotocol(FAR sem_t *sem, int protocol)
/* Remove any current holders */
sem_destroyholder(sem);
#endif
return OK;
case SEM_PRIO_INHERIT:
#ifdef CONFIG_PRIORITY_INHERITANCE
/* Enable priority inheritance (dangerous) */
sem->flags &= ~PRIOINHERIT_FLAGS_DISABLE;
return OK;
#endif
case SEM_PRIO_PROTECT:
/* Not yet supported */
@@ -128,3 +126,5 @@ int sem_setprotocol(FAR sem_t *sem, int protocol)
set_errno(errcode);
return ERROR;
}
endif /* CONFIG_PRIORITY_INHERITANCE */