zhaoxiu-zeng commented on a change in pull request #5171:
URL: https://github.com/apache/incubator-nuttx/pull/5171#discussion_r779272625



##########
File path: sched/semaphore/sem_holder.c
##########
@@ -1200,4 +1211,31 @@ int nxsem_nfreeholders(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: nxsem_release_all
+ *
+ * Description:
+ *   Release all semphore holders for the task.
+ *
+ * Input Parameters:
+ *   stcb - TCB of the task
+ *
+ * Returned Value:
+ *   None
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+void nxsem_release_all(FAR struct tcb_s *htcb)
+{
+  while (htcb->holdsem != NULL)
+    {
+      FAR struct semholder_s *pholder = htcb->holdsem;
+      FAR sem_t *sem = pholder->sem;
+
+      nxsem_freeholder(sem, pholder);
+    }
+}

Review comment:
       Applied, thanks!

##########
File path: sched/semaphore/sem_holder.c
##########
@@ -86,30 +87,36 @@ static inline FAR struct semholder_s 
*nxsem_allocholder(sem_t *sem)
       g_freeholders    = pholder->flink;
       pholder->flink   = sem->hhead;
       sem->hhead       = pholder;
-
-      /* Make sure the initial count is zero */
-
-      pholder->counts  = 0;
     }
 #else
   if (sem->holder[0].htcb == NULL)
     {
       pholder          = &sem->holder[0];
-      pholder->counts  = 0;
     }
   else if (sem->holder[1].htcb == NULL)
     {
       pholder          = &sem->holder[1];
-      pholder->counts  = 0;
     }
 #endif
   else
     {
       serr("ERROR: Insufficient pre-allocated holders\n");
       pholder          = NULL;
+      DEBUGASSERT(pholder != NULL);

Review comment:
       Applied, thanks!




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