mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 01:05:08 +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
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