summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-07 13:28:18 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-07 13:46:16 +0200
commitb197fc40a7bec76e80bc364c1b080e340ef920e9 (patch)
treecde192d1d616c7f310317dc8c3f2f8c89d8d2068 /Kernel/Process.cpp
parentd6667e4cb85afb4a65aab25a4014920dfff9c6da (diff)
downloadserenity-b197fc40a7bec76e80bc364c1b080e340ef920e9.zip
Kernel: Port process thread lists to SpinLockProtectedValue
I had to move the thread list out of the protected base area of Process so that it could live with its lock (which needs to be mutable). Ideally it would live in the protected area, so maybe we can figure out a way to do that later.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index b417b6d40d..55cce1afd0 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -856,8 +856,9 @@ bool Process::remove_thread(Thread& thread)
ProtectedDataMutationScope scope { *this };
auto thread_cnt_before = m_thread_count.fetch_sub(1, AK::MemoryOrder::memory_order_acq_rel);
VERIFY(thread_cnt_before != 0);
- ScopedSpinLock thread_list_lock(m_thread_list_lock);
- m_thread_list.remove(thread);
+ thread_list().with([&](auto& thread_list) {
+ thread_list.remove(thread);
+ });
return thread_cnt_before == 1;
}
@@ -865,8 +866,9 @@ bool Process::add_thread(Thread& thread)
{
ProtectedDataMutationScope scope { *this };
bool is_first = m_thread_count.fetch_add(1, AK::MemoryOrder::memory_order_relaxed) == 0;
- ScopedSpinLock thread_list_lock(m_thread_list_lock);
- m_thread_list.append(thread);
+ thread_list().with([&](auto& thread_list) {
+ thread_list.append(thread);
+ });
return is_first;
}