13022591351 commented on code in PR #19982:
URL: https://github.com/apache/nuttx/pull/19982#discussion_r3885647913


##########
libs/libc/wqueue/work_queue.c:
##########
@@ -115,13 +144,9 @@ static int work_qqueue(FAR struct usr_wqueue_s *wqueue,
    * We should wake up the worker thread.
    */
 
-  if (curr == head)
+  if (delay == 0 || curr == head)

Review Comment:
   This is needed for multi-worker custom queues. curr == head only detects 
when the new work becomes the earliest queue entry. A zero-delay work item may 
be inserted behind another already-ready item, so curr != head even though the 
new item is immediately runnable. Waking again allows another idle worker in 
the pool to process it without waiting for the first worker to dequeue the 
current head.
   
   Without this check the work would still eventually run, because the first 
worker wakes another worker after dequeuing a ready item, but parallel dispatch 
would be delayed. work_wake() bounds wake tokens by nthreads, and this also 
matches the scheduler backend, which posts the semaphore for every zero-delay 
work item.
   
   I will update the comment to make this intent explicit



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to