You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/09/05 13:58:27 UTC

[GitHub] [incubator-nuttx] acassis commented on a diff in pull request #6987: nuttx/sched: semaphore and mqueue task list optimize

acassis commented on code in PR #6987:
URL: https://github.com/apache/incubator-nuttx/pull/6987#discussion_r962936162


##########
sched/semaphore/sem_post.c:
##########
@@ -139,38 +139,32 @@ int nxsem_post(FAR sem_t *sem)
            * that we want.
            */
 
+#ifndef CONFIG_TASK_LIST_OPTIMIZE
           for (stcb = (FAR struct tcb_s *)g_waitingforsemaphore.head;
                (stcb && stcb->waitsem != sem);
                stcb = stcb->flink);
+#else
+          /* When enable task list optimize, remove TCB in semaphore waiting
+           * list before set waitsem to null.
+           */
 
-          if (stcb != NULL)
-            {
-              /* The task will be the new holder of the semaphore when
-               * it is awakened.
-               */
-
-              nxsem_add_holder_tcb(stcb, sem);
+          stcb = (FAR struct tcb_s *)dq_remfirst(SEM_WAIT_TLIST(sem));
+#endif
+          DEBUGASSERT(stcb != NULL);
 
-              /* Stop the watchdog timer */
+          nxsem_add_holder_tcb(stcb, sem);
 
-              wd_cancel(&stcb->waitdog);
+          /* Stop the watchdog timer */
 
-              /* It is, let the task take the semaphore */
+          wd_cancel(&stcb->waitdog);
 
-              stcb->waitsem = NULL;
+          /* It is, let the task take the semaphore */
 
-              /* Restart the waiting task. */
+          stcb->waitsem = NULL;
 
-              up_unblock_task(stcb);
-            }
-#if 0 /* REVISIT:  This can fire on IOB throttle semaphore */
-          else
-            {
-              /* This should not happen. */
+          /* Restart the waiting task. */
 
-              DEBUGPANIC();
-            }
-#endif

Review Comment:
   I think "stcb == NULL" condiction still exist when "#ifndef CONFIG_TASK_LIST_OPTIMIZE", why did you removed the REVISIT comment? Did you analyze all the options?



-- 
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-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org