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 2021/07/01 21:12:48 UTC

[GitHub] [incubator-nuttx] davids5 commented on a change in pull request #4035: work_queue: schedule the work queue using the timer mechanism

davids5 commented on a change in pull request #4035:
URL: https://github.com/apache/incubator-nuttx/pull/4035#discussion_r662477407



##########
File path: sched/wqueue/kwork_cancel.c
##########
@@ -77,18 +77,30 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue,
   flags = enter_critical_section();
   if (work->worker != NULL)
     {
-      /* A little test of the integrity of the work queue */
-
-      DEBUGASSERT(work->dq.flink != NULL ||
-                  (FAR dq_entry_t *)work == wqueue->q.tail);
-      DEBUGASSERT(work->dq.blink != NULL ||
-                  (FAR dq_entry_t *)work == wqueue->q.head);
-
       /* Remove the entry from the work queue and make sure that it is
        * marked as available (i.e., the worker field is nullified).
        */
 
-      dq_rem((FAR dq_entry_t *)work, &wqueue->q);
+      if (WDOG_ISACTIVE(&work->timer))
+        {
+          wd_cancel(&work->timer);
+        }
+      else
+        {
+          /* The sem_wait() can't call from interrupt handlers, so worker
+           * thread will still be awakened even if the work cancel is
+           * called in interrupt handlers, but work thread can handle
+           * this case with work empty in the work queue.
+           */
+
+          if (up_interrupt_context() == false)
+            {
+              nxsem_wait(&wqueue->sem);
+            }
+
+          sq_rem((FAR sq_entry_t *)work, &wqueue->q);
+        }
+

Review comment:
       This is running with interrupts off.
   Why is this not a remove item from queue and cancel if active?  




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