mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
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:
@@ -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)
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user