xiaoxiang781216 commented on code in PR #16360: URL: https://github.com/apache/nuttx/pull/16360#discussion_r2084594418
########## libs/libc/semaphore/sem_post.c: ########## @@ -119,6 +119,9 @@ int sem_post(FAR sem_t *sem) int nxsem_post(FAR sem_t *sem) { + bool mutex; + bool use_fastpath = true; Review Comment: ```suggestion bool fastpath = true; ``` ########## libs/libc/semaphore/sem_trywait.c: ########## @@ -123,18 +126,64 @@ int nxsem_trywait(FAR sem_t *sem) #ifndef CONFIG_LIBC_ARCH_ATOMIC - if (NXSEM_IS_MUTEX(sem) + mutex = NXSEM_IS_MUTEX(sem); + + /* Disable fast path if priority protection is enabled on the semaphore */ + # ifdef CONFIG_PRIORITY_PROTECT - && (sem->flags & SEM_PRIO_MASK) != SEM_PRIO_PROTECT + if ((sem->flags & SEM_PRIO_MASK) == SEM_PRIO_PROTECT) + { + use_fastpath = false; + } # endif - ) + + /* Disable fast path on a counting semaphore with priority inheritance */ + +# ifdef CONFIG_PRIORITY_INHERITANCE + if (!mutex && (sem->flags & SEM_PRIO_MASK) != SEM_PRIO_NONE) Review Comment: why need check mutex? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org