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


##########
sched/wqueue/kwork_thread.c:
##########
@@ -148,30 +196,35 @@ static int work_thread(int argc, FAR char *argv[])
   kworker = (FAR struct kworker_s *)
             ((uintptr_t)strtoul(argv[2], NULL, 16));
 
-  flags = spin_lock_irqsave(&wqueue->lock);
-  sched_lock();
+  list_initialize(&q);
 
-  /* Loop forever */
+  /* Loop until wqueue->exit != 0.
+   * We do not need to enter the critical-section to access wqueue->exit.
+   * Because the only way to set wqueue->exit is to call work_queue_free().
+   */
 
   while (!wqueue->exit)
     {
+      irqstate_t flags = spin_lock_irqsave(&wqueue->lock);
+      sched_lock();
+
       /* And check each entry in the work queue.  Since we have disabled
        * interrupts we know:  (1) we will not be suspended unless we do
        * so ourselves, and (2) there will be no changes to the work queue
        */
 
+      /* Check if there is expired delayed work */
+
+      ticks = clock_systime_ticks();
+      work_expiration(wqueue, &q, ticks);

Review Comment:
   but how to wait until the callback finish in work_cancel_sync?



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