From 523fd6533e008cce85229b59ee58c552d565b87b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 22 Dec 2019 12:34:38 +0100 Subject: [PATCH] Kernel: Unlock the Process when exit()ing If there are more threads in a process when exit()ing, we need to give them a chance to unwind any kernel stacks. This means we have to unlock the process lock before giving control to the scheduler. Fixes #891 (together with all of the other "no more main thread" work.) --- Kernel/Thread.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 63abbeb310..f07b4b2d6b 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -178,8 +178,11 @@ void Thread::die_if_needed() if (!m_should_die) return; + m_process.big_lock().unlock_if_locked(); + InterruptDisabler disabler; set_state(Thread::State::Dying); + if (!Scheduler::is_active()) Scheduler::pick_next_and_switch_now(); }