GUIDINGLI commented on code in PR #16231: URL: https://github.com/apache/nuttx/pull/16231#discussion_r2055620048
########## sched/wqueue/kwork_thread.c: ########## @@ -216,17 +278,54 @@ static int work_thread(int argc, FAR char *argv[]) * posted. */ - wqueue->wait_count++; + /* Check the waiting queue */ + + has_next = false; + + if (!list_is_empty(&wqueue->pending)) + { + work = list_first_entry(&wqueue->pending, struct work_s, node); + + /* The work thread will go sleep until work->qtime */ + + ticks = work->qtime; + has_next = true; + } + spin_unlock_irqrestore(&wqueue->lock, flags); sched_unlock(); + /* Set the earliest expired work delay */ + + if (has_next) + { + /* If the earliest work has already expired. */ + + if (clock_compare(ticks, clock_systime_ticks())) Review Comment: the ticks base time is clock_systime_ticks() in line 208, and here must be has a continue ? ########## sched/wqueue/kwork_thread.c: ########## @@ -216,18 +288,49 @@ static int work_thread(int argc, FAR char *argv[]) * posted. */ + /* Check the waiting queue */ + + has_next = false; + + if (!list_is_empty(&wqueue->q)) + { + work = list_first_entry(&wqueue->q, struct work_s, node); + + /* The work thread will go sleep until work->qtime */ + + ticks = work->qtime; + has_next = true; + } + wqueue->wait_count++; spin_unlock_irqrestore(&wqueue->lock, flags); sched_unlock(); + /* Set the earliest expired work delay */ + + if (has_next) + { + /* If the earliest work has already expired. */ + + if (clock_compare(ticks, clock_systime_ticks())) + { + /* Continue the work thread loop. */ + + continue; + } + + /* Else we start a time to wake up the work thread. */ + + wd_start_abstick(&wqueue->timer, ticks, work_timer_expired, Review Comment: how about the NTHREDS > 1, and the list only has one, so the each thread will setup their own wdog(but the same value) to wake thread -- 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