diff --git a/kernel/include/kswap.h b/kernel/include/kswap.h index a00f33846f8..917315d5899 100644 --- a/kernel/include/kswap.h +++ b/kernel/include/kswap.h @@ -90,6 +90,8 @@ static ALWAYS_INLINE unsigned int do_swap(unsigned int key, z_check_stack_sentinel(); + old_thread->swap_retval = -EAGAIN; + /* We always take the scheduler spinlock if we don't already * have it. We "release" other spinlocks here. But we never * drop the interrupt lock. @@ -108,8 +110,6 @@ static ALWAYS_INLINE unsigned int do_swap(unsigned int key, z_reset_time_slice(); #endif - old_thread->swap_retval = -EAGAIN; - #ifdef CONFIG_SMP _current_cpu->swap_ok = 0; new_thread->base.cpu = arch_curr_cpu()->id;