From 3ad6ae18426238e5292efe62153fda4fd4e4723f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 1 Aug 2019 20:01:23 +0200 Subject: Kernel: Delete non-main threads immediately after finalizing them Previously we would wait until the whole process died before actually deleting its threads. --- Kernel/Thread.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Kernel') diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index af93bbbb95..d9fa8f4413 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -157,15 +157,22 @@ const char* Thread::state_string() const void Thread::finalize() { + ASSERT(current == g_finalizer); + dbgprintf("Finalizing Thread %u in %s(%u)\n", tid(), m_process.name().characters(), pid()); set_state(Thread::State::Dead); - if (this == &m_process.main_thread()) + if (this == &m_process.main_thread()) { m_process.finalize(); + return; + } + + delete this; } void Thread::finalize_dying_threads() { + ASSERT(current == g_finalizer); Vector dying_threads; { InterruptDisabler disabler; -- cgit v1.2.3