summaryrefslogtreecommitdiff
path: root/Kernel/Thread.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-02-04 14:11:35 +0000
committerAndreas Kling <kling@serenityos.org>2023-02-06 20:36:53 +0100
commit1014aefe649aa50d69aa10aba647872e2ff99a93 (patch)
tree323d31d45de5bda44dad6cc5e3215ba910467877 /Kernel/Thread.cpp
parentfe7b08dad7a41251469840ab15ab90bc9b31caa8 (diff)
downloadserenity-1014aefe649aa50d69aa10aba647872e2ff99a93.zip
Kernel: Protect Thread::m_name with a spinlock
This replaces manually grabbing the thread's main lock. This lets us remove the `get_thread_name` and `set_thread_name` syscalls from the big lock. :^)
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r--Kernel/Thread.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 0c047e4df8..28f8a0d6ea 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -1466,6 +1466,14 @@ void Thread::track_lock_release(LockRank rank)
m_lock_rank_mask ^= rank;
}
+
+void Thread::set_name(NonnullOwnPtr<KString> name)
+{
+ m_name.with([&](auto& this_name) {
+ this_name = move(name);
+ });
+}
+
}
ErrorOr<void> AK::Formatter<Kernel::Thread>::format(FormatBuilder& builder, Kernel::Thread const& value)