zyfeier commented on PR #8175:
URL: https://github.com/apache/nuttx/pull/8175#issuecomment-1396582225

   > But I do not see that pholder code modifies sem count value. How is this 
different from the case without priority inheritance enabled? And is the same 
issue exists in non-SMP case?
   
   1. The situation is even worse if priority inheritance is not enabled, 
because no holder information was recorded.
   2. non-SMP is the same.
   
   If the task is released while waiting for sem, nxsem_recover() function will 
release the count:
   
   ```
     if (tcb->task_state == TSTATE_WAIT_SEM)
       {
         FAR sem_t *sem = tcb->waitobj;
         DEBUGASSERT(sem != NULL && sem->semcount < 0);
   
         /* Restore the correct priority of all threads that hold references
          * to this semaphore.
          */
   
         nxsem_canceled(tcb, sem);
   
         /* And increment the count on the semaphore.  This releases the count
          * that was taken by sem_wait().  This count decremented the semaphore
          * count to negative and caused the thread to be blocked in the first
          * place.
          */
   
         sem->semcount++;
       }
   ```
   
   But, when the task hold the mutex,  count was not released by 
nxsem_release_all().


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