From 23902d46f1c02143186f30075e47bb10e4a603c1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 19 Aug 2022 13:59:15 +0200 Subject: [PATCH] Kernel: Don't lock scheduler in ~Thread() This is not necessary, and is a leftover from before Thread started using the ListedRefCounted pattern to be safely removed from lists on the last call to unref(). --- Kernel/Thread.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index f787e55881..a47908d595 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -133,19 +133,10 @@ Thread::Thread(NonnullRefPtr process, NonnullOwnPtr ker Thread::~Thread() { - { - // We need to explicitly remove ourselves from the thread list - // here. We may get preempted in the middle of destructing this - // thread, which causes problems if the thread list is iterated. - // Specifically, if this is the last thread of a process, checking - // block conditions would access m_process, which would be in - // the middle of being destroyed. - SpinlockLocker lock(g_scheduler_lock); - VERIFY(!m_process_thread_list_node.is_in_list()); + VERIFY(!m_process_thread_list_node.is_in_list()); - // We shouldn't be queued - VERIFY(m_runnable_priority < 0); - } + // We shouldn't be queued + VERIFY(m_runnable_priority < 0); } Thread::BlockResult Thread::block_impl(BlockTimeout const& timeout, Blocker& blocker)