jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2071315094
########## sched/semaphore/sem_reset.c: ########## @@ -76,38 +81,65 @@ int nxsem_reset(FAR sem_t *sem, int16_t count) flags = enter_critical_section(); - /* A negative count indicates that the negated number of threads are - * waiting to take a count from the semaphore. Loop here, handing - * out counts to any waiting threads. - */ - - while (atomic_read(NXSEM_COUNT(sem)) < 0 && count > 0) + if (NXSEM_IS_MUTEX(sem)) { - /* Give out one counting, waking up one of the waiting threads - * and, perhaps, kicking off a lot of priority inheritance - * logic (REVISIT). + /* Support only resetting mutex by removing one waiter */ + + DEBUGASSERT(count == 1); + + /* Post the mutex once with holder value set to RESET | BLOCKS + * so we know that it is ok in this case to call the post from + * another thread. */ - DEBUGVERIFY(nxsem_post(sem)); - count--; + atomic_set(NXSEM_MHOLDER(sem), + NXSEM_MRESET | NXSEM_MBLOCKS_BIT); + + if (dq_peek(SEM_WAITLIST(sem)) != NULL) Review Comment: I missed this one, sorry, will update -- 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