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


##########
sched/semaphore/sem_post.c:
##########
@@ -116,7 +153,10 @@ int nxsem_post_slow(FAR sem_t *sem)
    * initialized if the semaphore is to used for signaling purposes.
    */
 
-  nxsem_release_holder(sem);
+  if (!mutex || blocking)

Review Comment:
   > Can you please explain what you mean. You need to add the holder to 
tcb->holdsem list for the priority inheritance / restoration.
   > 
   
   No, we don't need add a new field like `holdsem`, we can restore holder tcb 
from `sem->u.mholder`.
   
   > I am definitely not going to remove those. A thread can hold several 
mutexes and priority can be boosted many times. To restore the priority to 
correct level you need to have the semaphores (holder structures) added to the 
tcb:s list (holdsem list).
   
   Yes, but all priority adjust trigger happen when someone operate on 
semaphore. At this case, we can restore the holder tcb from `sem->u.mholder`. 
with the new implementation:
   
   1. Binary semaphore(mutex) already record the only holder in `u.mholder` 
field, we don't need add it into `holder/hhead` again
   2. Adjust nxsem_boost_priority/nxsem_restore_baseprio to consider the 
special holder in `u.mholder` for mutex
   3. Change the default value of SEM_PREALLOCHOLDERS to zero
   
   These suggestion could satisfy:
   
   1. Binary semaphore work without SEM_PREALLOCHOLDERS
   2. Support the multiple holders for counting semaphore
   



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