kernel/queue: Fix SMP race

Calling z_ready_thread() means the thread is now ready and can wake up
at any moment on another CPU.  But we weren't finished setting the
return value!  So the other side could wake up with a spurious "error"
condition if it ran too soon.  Note that on systems with a working
IPI, that wakeup can happen much faster than you might think.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2020-01-17 10:43:26 -08:00 committed by Andrew Boie
commit 4c2fc2aed7

View file

@ -103,8 +103,8 @@ static inline void z_vrfy_k_queue_init(struct k_queue *queue)
#if !defined(CONFIG_POLL)
static void prepare_thread_to_run(struct k_thread *thread, void *data)
{
z_ready_thread(thread);
z_thread_return_value_set_with_data(thread, 0, data);
z_ready_thread(thread);
}
#endif /* CONFIG_POLL */