mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
libc/semaphore:sem_init change defult protocol
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
@@ -98,6 +98,7 @@ static inline int nxmutex_init(FAR mutex_t *mutex)
|
|||||||
return _SEM_ERRVAL(ret);
|
return _SEM_ERRVAL(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_SEM_SETPROTOCOL(mutex, SEM_PRIO_INHERIT);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -48,7 +48,10 @@
|
|||||||
|
|
||||||
/* Bit definitions for the struct sem_s flags field */
|
/* 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. */
|
* is disabled for this semaphore. */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -55,13 +55,13 @@ int sem_getprotocol(FAR sem_t *sem, FAR int *protocol)
|
|||||||
DEBUGASSERT(sem != NULL && protocol != NULL);
|
DEBUGASSERT(sem != NULL && protocol != NULL);
|
||||||
|
|
||||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
#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
|
else
|
||||||
{
|
{
|
||||||
*protocol = SEM_PRIO_INHERIT;
|
*protocol = SEM_PRIO_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -707,7 +707,7 @@ void nxsem_add_holder_tcb(FAR struct tcb_s *htcb, FAR sem_t *sem)
|
|||||||
* inheritance is effectively disabled.
|
* 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 */
|
/* 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 */
|
/* Disable priority inheritance */
|
||||||
|
|
||||||
sem->flags |= PRIOINHERIT_FLAGS_DISABLE;
|
sem->flags &= ~PRIOINHERIT_FLAGS_ENABLE;
|
||||||
|
|
||||||
/* Remove any current holders */
|
/* Remove any current holders */
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ int nxsem_set_protocol(FAR sem_t *sem, int protocol)
|
|||||||
|
|
||||||
/* Enable priority inheritance (dangerous) */
|
/* Enable priority inheritance (dangerous) */
|
||||||
|
|
||||||
sem->flags &= ~PRIOINHERIT_FLAGS_DISABLE;
|
sem->flags |= PRIOINHERIT_FLAGS_ENABLE;
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
case SEM_PRIO_PROTECT:
|
case SEM_PRIO_PROTECT:
|
||||||
|
|||||||
Reference in New Issue
Block a user