libc/semaphore:sem_init change defult protocol
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
parent
e1ca516488
commit
577e550698
|
@ -98,6 +98,7 @@ static inline int nxmutex_init(FAR mutex_t *mutex)
|
|||
return _SEM_ERRVAL(ret);
|
||||
}
|
||||
|
||||
_SEM_SETPROTOCOL(mutex, SEM_PRIO_INHERIT);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,10 @@
|
|||
|
||||
/* Bit definitions for the struct sem_s flags field */
|
||||
|
||||
#define PRIOINHERIT_FLAGS_DISABLE (1 << 0) /* Bit 0: Priority inheritance
|
||||
#define PRIOINHERIT_FLAGS_ENABLE (1 << 0) /* Bit 0: Priority inheritance
|
||||
* is enabled for this semaphore. */
|
||||
|
||||
#define PRIOINHERIT_FLAGS_DISABLE (0 << 0) /* Bit 0: Priority inheritance
|
||||
* is disabled for this semaphore. */
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -55,13 +55,13 @@ int sem_getprotocol(FAR sem_t *sem, FAR int *protocol)
|
|||
DEBUGASSERT(sem != NULL && protocol != NULL);
|
||||
|
||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||
if ((sem->flags & PRIOINHERIT_FLAGS_DISABLE) != 0)
|
||||
if ((sem->flags & PRIOINHERIT_FLAGS_ENABLE) != 0)
|
||||
{
|
||||
*protocol = SEM_PRIO_NONE;
|
||||
*protocol = SEM_PRIO_INHERIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
*protocol = SEM_PRIO_INHERIT;
|
||||
*protocol = SEM_PRIO_NONE;
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -707,7 +707,7 @@ void nxsem_add_holder_tcb(FAR struct tcb_s *htcb, FAR sem_t *sem)
|
|||
* inheritance is effectively disabled.
|
||||
*/
|
||||
|
||||
if (htcb->flink != NULL && (sem->flags & PRIOINHERIT_FLAGS_DISABLE) == 0)
|
||||
if (htcb->flink != NULL && (sem->flags & PRIOINHERIT_FLAGS_ENABLE) != 0)
|
||||
{
|
||||
/* Find or allocate a container for this new holder */
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ int nxsem_set_protocol(FAR sem_t *sem, int protocol)
|
|||
|
||||
/* Disable priority inheritance */
|
||||
|
||||
sem->flags |= PRIOINHERIT_FLAGS_DISABLE;
|
||||
sem->flags &= ~PRIOINHERIT_FLAGS_ENABLE;
|
||||
|
||||
/* Remove any current holders */
|
||||
|
||||
|
@ -93,7 +93,7 @@ int nxsem_set_protocol(FAR sem_t *sem, int protocol)
|
|||
|
||||
/* Enable priority inheritance (dangerous) */
|
||||
|
||||
sem->flags &= ~PRIOINHERIT_FLAGS_DISABLE;
|
||||
sem->flags |= PRIOINHERIT_FLAGS_ENABLE;
|
||||
return OK;
|
||||
|
||||
case SEM_PRIO_PROTECT:
|
||||
|
|
Loading…
Reference in New Issue