Skip to content

Commit 3dea408

Browse files
Andy Rossgalak
authored andcommitted
kernel/sched: Flag DEAD on correct thread in cross-CPU abort
Daniel Leung caught a good one: In the (SMP) case where we were aborting a thread that was not currently scheduled, we were flagging the DEAD state on _current and not the thread we were aborting! This wasn't as fatal as it seems, as the thread that called z_sched_abort() would effectively go on living (as a zombie?) in a state where it would always be preempted, but would otherwise remain scheduleable. Signed-off-by: Andy Ross <[email protected]>
1 parent 41e9063 commit 3dea408

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/sched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ void z_sched_abort(struct k_thread *thread)
10301030
while ((thread->base.thread_state & _THREAD_DEAD) == 0) {
10311031
LOCKED(&sched_spinlock) {
10321032
if (z_is_thread_queued(thread)) {
1033-
_current->base.thread_state |= _THREAD_DEAD;
1033+
thread->base.thread_state |= _THREAD_DEAD;
10341034
_priq_run_remove(&_kernel.ready_q.runq, thread);
10351035
z_mark_thread_as_not_queued(thread);
10361036
}

0 commit comments

Comments
 (0)