Skip to content

Commit

Permalink
libc/semaphore:sem_init change defult protocol
Browse files Browse the repository at this point in the history
Signed-off-by: anjiahao <[email protected]>
  • Loading branch information
anjiahao1 committed Dec 24, 2021
1 parent 509350a commit 9d14eb6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion drivers/input/tsc2007.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ int tsc2007_register(FAR struct i2c_master_s *dev,
* have priority inheritance enabled.
*/

nxsem_set_protocol(&priv->waitsem, SEM_PRIO_NONE);
nxsem_set_protocol(&priv->devsem, SEM_PRIO_INHERIT);

/* Make sure that interrupts are disabled */

Expand Down
4 changes: 2 additions & 2 deletions include/semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@

/* Bit definitions for the struct sem_s flags field */

#define PRIOINHERIT_FLAGS_DISABLE (1 << 0) /* Bit 0: Priority inheritance
* is disabled for this semaphore. */
#define PRIOINHERIT_FLAGS_ENABLE (1 << 0) /* Bit 0: Priority inheritance
* is enable for this semaphore. */

/****************************************************************************
* Public Type Declarations
Expand Down
2 changes: 1 addition & 1 deletion libs/libc/semaphore/sem_getprotocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ 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;
}
Expand Down
2 changes: 1 addition & 1 deletion sched/semaphore/sem_holder.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ void nxsem_add_holder_tcb(FAR struct tcb_s *htcb, FAR sem_t *sem)
* inheritance is effectively disabled.
*/

if ((sem->flags & PRIOINHERIT_FLAGS_DISABLE) == 0)
if ((sem->flags & PRIOINHERIT_FLAGS_ENABLE) == 1)
{
/* Find or allocate a container for this new holder */

Expand Down
4 changes: 2 additions & 2 deletions sched/semaphore/sem_setprotocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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:
Expand Down

0 comments on commit 9d14eb6

Please sign in to comment.