Fix-Point commented on code in PR #16231: URL: https://github.com/apache/nuttx/pull/16231#discussion_r2049949011
########## sched/wqueue/kwork_queue.c: ########## @@ -155,49 +94,48 @@ int work_queue_period_wq(FAR struct kwork_wqueue_s *wqueue, flags = spin_lock_irqsave(&wqueue->lock); sched_lock(); - /* Remove the entry from the timer and work queue. */ + /* Check whether we own the work structure. */ if (work->worker != NULL) { - /* Remove the entry from the work queue and make sure that it is - * marked as available (i.e., the worker field is nullified). - */ + /* Seize the ownership from the work thread. */ work->worker = NULL; - wd_cancel(&work->u.timer); - list_delete(&work->u.s.node); - } - - if (work_is_canceling(wqueue->worker, wqueue->nthreads, work)) - { - goto out; + list_delete(&work->node); } /* Initialize the work structure. */ work->worker = worker; /* Work callback. non-NULL means queued */ work->arg = arg; /* Callback argument */ - work->wq = wqueue; /* Work queue */ + work->period = period; /* Periodical delay */ /* Queue the new work */ if (!delay) { - queue_work(wqueue, work); + work->qtime = clock_systime_ticks(); + + list_add_tail(&wqueue->q, &work->node); } - else if (period == 0) + else { - ret = wd_start(&work->u.timer, delay, - work_timer_expiry, (wdparm_t)work); + /* Insert the work to the workqueue's waiting list. */ + + work->qtime = clock_systime_ticks() + delay + 1; + + work_insert_waitq(wqueue, work); } - else + + /* Wakeup the wqueue thread. */ + + if (wqueue->wait_count > 0) /* There are threads waiting for sem. */ { - ret = wd_start_period(&work->u.ptimer, delay, period, - work_timer_expiry, (wdparm_t)work); + wqueue->wait_count--; + nxsem_post(&wqueue->sem); } -out: spin_unlock_irqrestore(&wqueue->lock, flags); Review Comment: I will try this in the next patch. -- 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