1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

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. :^)
This commit is contained in:
Sam Atkins 2023-02-04 14:11:35 +00:00 committed by Andreas Kling
parent fe7b08dad7
commit 1014aefe64
5 changed files with 27 additions and 27 deletions

View file

@ -94,19 +94,11 @@ public:
Process& process() { return m_process; }
Process const& process() const { return m_process; }
// NOTE: This returns a null-terminated string.
StringView name() const
SpinlockProtected<NonnullOwnPtr<KString>, LockRank::None> const& name() const
{
// NOTE: Whoever is calling this needs to be holding our lock while reading the name.
VERIFY(m_lock.is_locked_by_current_processor());
return m_name->view();
}
void set_name(NonnullOwnPtr<KString> name)
{
SpinlockLocker lock(m_lock);
m_name = move(name);
return m_name;
}
void set_name(NonnullOwnPtr<KString> name);
void finalize();
@ -1229,7 +1221,7 @@ private:
FPUState m_fpu_state {};
State m_state { Thread::State::Invalid };
NonnullOwnPtr<KString> m_name;
SpinlockProtected<NonnullOwnPtr<KString>, LockRank::None> m_name;
u32 m_priority { THREAD_PRIORITY_NORMAL };
State m_stop_state { Thread::State::Invalid };