Skip to content

Commit

Permalink
sched/wqueue: fix issue about worker can't wake up thread before work…
Browse files Browse the repository at this point in the history
…_thread running

Problem:
AppBringup task in default priority 240 ->
board_late_initialize() ->
   some driver called work_queue() ->
      nxsem_post(&(wqueue).sem) failed because sem_count is 0

hp work_thread in default priority 224 ->
      nxsem_wait_uninterruptible(&wqueue->sem);

so hp_work_thread can't wake up, worker can't run immediately.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
  • Loading branch information
Donny9 authored and xiaoxiang781216 committed Apr 18, 2023
1 parent ab1b3c0 commit 1f665e3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sched/wqueue/kwork_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,6 @@ static int work_thread(int argc, FAR char *argv[])

for (; ; )
{
/* Then process queued work. work_process will not return until: (1)
* there is no further work in the work queue, and (2) semaphore is
* posted.
*/

nxsem_wait_uninterruptible(&wqueue->sem);

/* 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
Expand Down Expand Up @@ -182,6 +175,13 @@ static int work_thread(int argc, FAR char *argv[])
CALL_WORKER(worker, arg);
flags = enter_critical_section();
}

/* Then process queued work. work_process will not return until: (1)
* there is no further work in the work queue, and (2) semaphore is
* posted.
*/

nxsem_wait_uninterruptible(&wqueue->sem);
}

leave_critical_section(flags);
Expand Down

0 comments on commit 1f665e3

Please sign in to comment.