Fix-Point commented on code in PR #16231:
URL: https://github.com/apache/nuttx/pull/16231#discussion_r2051350753


##########
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();

Review Comment:
   In next patch I'll try to optimize the synchronization.



##########
sched/wqueue/kwork_thread.c:
##########
@@ -110,6 +114,48 @@ struct lp_wqueue_s g_lpwork =
  * Private Functions
  ****************************************************************************/
 
+/* The work time expired callback will wake up the worker thread. */
+
+static void work_timer_expired(wdparm_t arg)
+{
+  FAR struct kwork_wqueue_s *wq = (FAR struct kwork_wqueue_s *)arg;
+  irqstate_t flags = spin_lock_irqsave(&wq->lock);
+  sched_lock();
+
+  if (wq->wait_count > 0)

Review Comment:
   OK. I'll create a new patch after this.



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