From 8cad2dc90548b3a5f0218b55df80c641fd777e7c Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 14 Apr 2015 15:54:34 +0200 Subject: Work queue: Yield between queue items to ensure queue execution stays in lockstep with main OS tasks scheduling on priorities. --- nuttx/libc/wqueue/work_thread.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nuttx/libc/wqueue/work_thread.c b/nuttx/libc/wqueue/work_thread.c index 6ef8a874b..2b8f52d44 100644 --- a/nuttx/libc/wqueue/work_thread.c +++ b/nuttx/libc/wqueue/work_thread.c @@ -161,6 +161,13 @@ static void work_process(FAR struct wqueue_s *wqueue) irqrestore(flags); worker(arg); + /* Yield scheduling once - we need this as the work queue items will else + * always execute before tasks which have become ready to run in the meantime. + * If no same or higher priority task is ready this will have no effect, if a + * task is ready we will return here after it executed. + */ + sched_yield(); + /* Now, unfortunately, since we re-enabled interrupts we don't * know the state of the work list and we will have to start * back at the head of the list. -- cgit v1.2.3