kernel/sem: Fix SMP race
This had the same race that queue did: you have to be 100% done with state management before calling z_ready_thread(), because another CPU can pick up the thread before the return value was set. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
5b85d6da6a
commit
b8ff63e3c7
1 changed files with 1 additions and 1 deletions
|
@ -113,8 +113,8 @@ void z_impl_k_sem_give(struct k_sem *sem)
|
|||
sys_trace_void(SYS_TRACE_ID_SEMA_GIVE);
|
||||
|
||||
if (thread != NULL) {
|
||||
z_ready_thread(thread);
|
||||
arch_thread_return_value_set(thread, 0);
|
||||
z_ready_thread(thread);
|
||||
} else {
|
||||
sem->count += (sem->count != sem->limit) ? 1U : 0U;
|
||||
handle_poll_events(sem);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue