pussuw commented on code in PR #16194:
URL: https://github.com/apache/nuttx/pull/16194#discussion_r2044380461


##########
sched/semaphore/sem_holder.c:
##########
@@ -970,11 +972,32 @@ void nxsem_release_all(FAR struct tcb_s *htcb)
 
       nxsem_freeholder(sem, pholder);
 
-      /* Increment the count on the semaphore, to releases the count
-       * that was taken by sem_wait() or sem_post().
-       */
+      if (!NXSEM_IS_MUTEX(sem))
+        {
+          /* Increment the count on the semaphore, to releases the count
+           * that was taken by sem_wait() or sem_post().
+           */
+
+          atomic_fetch_add(NXSEM_COUNT(sem), 1);
+        }
+      else
+        {
+          /* Lock the mutex for us by setting the blocking bit. We are in
+           * critical section
+           */
 
-      atomic_fetch_add(NXSEM_COUNT(sem), 1);
+          nxsem_get_mholder_acquire(sem);

Review Comment:
   Another way would be to release the mutex and let the waiters contend for 
it. When a context switch occurs, the highest priority waiter should be 
released anyhow?



-- 
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

Reply via email to