mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 14:19:48 +00:00
Kernel: Keep a list of threads per Process
This allow us to iterate only the threads of the process.
This commit is contained in:
parent
03a9ee79fa
commit
ac3927086f
Notes:
sideshowbarker
2024-07-18 22:48:38 +09:00
Author: https://github.com/tomuta
Commit: ac3927086f
Pull-request: https://github.com/SerenityOS/serenity/pull/5073
4 changed files with 45 additions and 28 deletions
|
@ -907,4 +907,22 @@ PerformanceEventBuffer& Process::ensure_perf_events()
|
|||
m_perf_event_buffer = make<PerformanceEventBuffer>();
|
||||
return *m_perf_event_buffer;
|
||||
}
|
||||
|
||||
bool Process::remove_thread(Thread& thread)
|
||||
{
|
||||
auto thread_cnt_before = m_thread_count.fetch_sub(1, AK::MemoryOrder::memory_order_acq_rel);
|
||||
ASSERT(thread_cnt_before != 0);
|
||||
ScopedSpinLock thread_list_lock(m_thread_list_lock);
|
||||
m_thread_list.remove(thread);
|
||||
return thread_cnt_before == 1;
|
||||
}
|
||||
|
||||
bool Process::add_thread(Thread& thread)
|
||||
{
|
||||
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);
|
||||
return is_first;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue