Skip to content

Commit

Permalink
Kernel: Switch ProcessGroup to IntrusiveList from InlineLinkedList
Browse files Browse the repository at this point in the history
  • Loading branch information
bgianfo authored and awesomekling committed Jun 3, 2021
1 parent ce74fce commit 7e691f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Kernel/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions Kernel/ProcessGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
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)
{
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;
Expand Down
16 changes: 7 additions & 9 deletions Kernel/ProcessGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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();

Expand All @@ -40,13 +37,14 @@ class ProcessGroup
{
}

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;

}

0 comments on commit 7e691f9

Please sign in to comment.