kernel: fix race condition when spawning a thread with a delay

Interrupt must be locked before inserting a timeout in the timeout
queue.

Change-Id: Iab0bf01f393e66a6403d2f85e899dbf737da4afc
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
Benjamin Walsh 2016-11-30 17:41:16 -05:00 committed by Anas Nashif
commit f421ec23ad

View file

@ -221,8 +221,10 @@ static void schedule_new_thread(struct k_thread *thread, int32_t delay)
start_thread(thread);
} else {
int32_t ticks = _TICK_ALIGN + _ms_to_ticks(delay);
int key = irq_lock();
_add_thread_timeout(thread, NULL, ticks);
irq_unlock(key);
}
#else
ARG_UNUSED(delay);