mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:37:34 +00:00
Kernel: Switch ProcessGroup to IntrusiveList from InlineLinkedList
This commit is contained in:
parent
ce74fce0df
commit
7e691f96e1
3 changed files with 11 additions and 13 deletions
|
@ -62,7 +62,7 @@ UNMAP_AFTER_INIT void Process::initialize()
|
||||||
|
|
||||||
next_pid.store(0, AK::MemoryOrder::memory_order_release);
|
next_pid.store(0, AK::MemoryOrder::memory_order_release);
|
||||||
g_processes = new InlineLinkedList<Process>;
|
g_processes = new InlineLinkedList<Process>;
|
||||||
g_process_groups = new InlineLinkedList<ProcessGroup>;
|
g_process_groups = new ProcessGroup::List();
|
||||||
g_hostname = new String("courage");
|
g_hostname = new String("courage");
|
||||||
g_hostname_lock = new Lock;
|
g_hostname_lock = new Lock;
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
RecursiveSpinLock g_process_groups_lock;
|
RecursiveSpinLock g_process_groups_lock;
|
||||||
InlineLinkedList<ProcessGroup>* g_process_groups;
|
ProcessGroup::List* g_process_groups;
|
||||||
|
|
||||||
ProcessGroup::~ProcessGroup()
|
ProcessGroup::~ProcessGroup()
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(g_process_groups_lock);
|
ScopedSpinLock lock(g_process_groups_lock);
|
||||||
g_process_groups->remove(this);
|
g_process_groups->remove(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<ProcessGroup> ProcessGroup::create(ProcessGroupID pgid)
|
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));
|
auto process_group = adopt_ref_if_nonnull(new ProcessGroup(pgid));
|
||||||
if (process_group) {
|
if (process_group) {
|
||||||
ScopedSpinLock lock(g_process_groups_lock);
|
ScopedSpinLock lock(g_process_groups_lock);
|
||||||
g_process_groups->prepend(process_group);
|
g_process_groups->prepend(*process_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
return process_group;
|
return process_group;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/InlineLinkedList.h>
|
#include <AK/IntrusiveList.h>
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <AK/Weakable.h>
|
#include <AK/Weakable.h>
|
||||||
#include <Kernel/Lock.h>
|
#include <Kernel/Lock.h>
|
||||||
|
@ -17,14 +17,11 @@ namespace Kernel {
|
||||||
|
|
||||||
class ProcessGroup
|
class ProcessGroup
|
||||||
: public RefCounted<ProcessGroup>
|
: public RefCounted<ProcessGroup>
|
||||||
, public Weakable<ProcessGroup>
|
, public Weakable<ProcessGroup> {
|
||||||
, public InlineLinkedListNode<ProcessGroup> {
|
|
||||||
|
|
||||||
AK_MAKE_NONMOVABLE(ProcessGroup);
|
AK_MAKE_NONMOVABLE(ProcessGroup);
|
||||||
AK_MAKE_NONCOPYABLE(ProcessGroup);
|
AK_MAKE_NONCOPYABLE(ProcessGroup);
|
||||||
|
|
||||||
friend InlineLinkedListNode<ProcessGroup>;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~ProcessGroup();
|
~ProcessGroup();
|
||||||
|
|
||||||
|
@ -40,13 +37,14 @@ private:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessGroup* m_prev { nullptr };
|
IntrusiveListNode<ProcessGroup> m_list_node;
|
||||||
ProcessGroup* m_next { nullptr };
|
|
||||||
|
|
||||||
ProcessGroupID m_pgid;
|
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;
|
extern RecursiveSpinLock g_process_groups_lock;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue