1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 11:07:45 +00:00

Kernel: Move Process's process group pointer into protected data

Now that it's no longer using LockRefPtr, we can actually move it into
protected data. (LockRefPtr couldn't be stored there because protected
data is immutable at times, and LockRefPtr uses some of its own bits
for locking.)
This commit is contained in:
Andreas Kling 2023-04-04 08:08:31 +02:00
parent 1c77803845
commit 1e2ef59965
3 changed files with 7 additions and 11 deletions

View file

@ -117,6 +117,7 @@ class Process final
SessionID sid { 0 };
// FIXME: This should be a NonnullRefPtr
RefPtr<Credentials> credentials;
RefPtr<ProcessGroup> process_group;
bool dumpable { false };
bool executable_is_setid { false };
Atomic<bool> has_promises { false };
@ -238,7 +239,7 @@ public:
bool is_session_leader() const { return sid().value() == pid().value(); }
ProcessGroupID pgid() const
{
return m_pg.with([&](auto& pg) { return pg ? pg->pgid() : 0; });
return with_protected_data([](auto& protected_data) { return protected_data.process_group ? protected_data.process_group->pgid() : 0; });
}
bool is_group_leader() const { return pgid().value() == pid().value(); }
ProcessID ppid() const
@ -681,8 +682,6 @@ private:
SpinlockProtected<OwnPtr<Memory::AddressSpace>, LockRank::None> m_space;
SpinlockProtected<RefPtr<ProcessGroup>, LockRank::None> m_pg;
RecursiveSpinlock<LockRank::None> mutable m_protected_data_lock;
AtomicEdgeAction<u32> m_protected_data_refs;
void protect_data();