summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-08-01 20:01:23 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-08-01 20:01:23 +0200
commit3ad6ae18426238e5292efe62153fda4fd4e4723f (patch)
treee5064562e313af69a9f72d9b543146c354a4c6e4 /Kernel
parent55d6efd48513ae7d92e5f5779dcbda5047063d5e (diff)
downloadserenity-3ad6ae18426238e5292efe62153fda4fd4e4723f.zip
Kernel: Delete non-main threads immediately after finalizing them
Previously we would wait until the whole process died before actually deleting its threads.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Thread.cpp9
1 files changed, 8 insertions, 1 deletions
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<Thread*, 32> dying_threads;
{
InterruptDisabler disabler;