pkarashchenko commented on code in PR #8951:
URL: https://github.com/apache/nuttx/pull/8951#discussion_r1158840012


##########
sched/semaphore/sem_holder.c:
##########
@@ -792,61 +697,54 @@ void nxsem_boost_priority(FAR sem_t *sem)
 void nxsem_release_holder(FAR sem_t *sem)
 {
   FAR struct tcb_s *rtcb = this_task();
-  FAR struct semholder_s *pholder;
-  FAR struct semholder_s *candidate = NULL;
-  unsigned int total = 0;
+  uint8_t prioinherit = sem->flags & SEM_PRIO_MASK;
+
+  /* If priority inheritance is disabled for this thread or it is IDLE
+   * thread, then do not add the holder.
+   * If there are never holders of the semaphore, the priority
+   * inheritance is effectively disabled.
+   */
+
+  if (!is_idle_task(rtcb) && prioinherit == SEM_PRIO_INHERIT)
+    {
+      FAR struct semholder_s *pholder;
 
-  /* Find the container for this holder */
+      DEBUGASSERT(!up_interrupt_context());

Review Comment:
   The question is only where we should check it. Semaphore holders APIs are 
internal APIs and interrupt context check may be done once in nxsem_post 
instead of two times like in this PR. On the other hand the current approach 
will catch possible misuse of semaphore holders APIs. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to