Kernel: Switch ProcessGroup to IntrusiveList from InlineLinkedList

This commit is contained in:
Brian Gianforcaro 2021-06-03 03:21:04 -07:00 committed by Andreas Kling
parent ce74fce0df
commit 7e691f96e1
Notes: sideshowbarker 2024-07-18 16:57:43 +09:00
3 changed files with 11 additions and 13 deletions

View file

@ -62,7 +62,7 @@ UNMAP_AFTER_INIT void Process::initialize()
next_pid.store(0, AK::MemoryOrder::memory_order_release);
g_processes = new InlineLinkedList<Process>;
g_process_groups = new InlineLinkedList<ProcessGroup>;
g_process_groups = new ProcessGroup::List();
g_hostname = new String("courage");
g_hostname_lock = new Lock;

View file

@ -9,12 +9,12 @@
namespace Kernel {
RecursiveSpinLock g_process_groups_lock;
InlineLinkedList<ProcessGroup>* g_process_groups;
ProcessGroup::List* g_process_groups;
ProcessGroup::~ProcessGroup()
{
ScopedSpinLock lock(g_process_groups_lock);
g_process_groups->remove(this);
g_process_groups->remove(*this);
}
RefPtr<ProcessGroup> ProcessGroup::create(ProcessGroupID pgid)
@ -22,7 +22,7 @@ RefPtr<ProcessGroup> ProcessGroup::create(ProcessGroupID pgid)
auto process_group = adopt_ref_if_nonnull(new ProcessGroup(pgid));
if (process_group) {
ScopedSpinLock lock(g_process_groups_lock);
g_process_groups->prepend(process_group);
g_process_groups->prepend(*process_group);
}
return process_group;

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/InlineLinkedList.h>
#include <AK/IntrusiveList.h>
#include <AK/RefCounted.h>
#include <AK/Weakable.h>
#include <Kernel/Lock.h>
@ -17,14 +17,11 @@ namespace Kernel {
class ProcessGroup
: public RefCounted<ProcessGroup>
, public Weakable<ProcessGroup>
, public InlineLinkedListNode<ProcessGroup> {
, public Weakable<ProcessGroup> {
AK_MAKE_NONMOVABLE(ProcessGroup);
AK_MAKE_NONCOPYABLE(ProcessGroup);
friend InlineLinkedListNode<ProcessGroup>;
public:
~ProcessGroup();
@ -40,13 +37,14 @@ private:
{
}
ProcessGroup* m_prev { nullptr };
ProcessGroup* m_next { nullptr };
IntrusiveListNode<ProcessGroup> m_list_node;
ProcessGroupID m_pgid;
public:
using List = IntrusiveList<ProcessGroup, RawPtr<ProcessGroup>, &ProcessGroup::m_list_node>;
};
extern InlineLinkedList<ProcessGroup>* g_process_groups;
extern ProcessGroup::List* g_process_groups;
extern RecursiveSpinLock g_process_groups_lock;
}