diff --git a/Kernel/GlobalProcessExposed.cpp b/Kernel/GlobalProcessExposed.cpp index f73a672a64..6388fc4825 100644 --- a/Kernel/GlobalProcessExposed.cpp +++ b/Kernel/GlobalProcessExposed.cpp @@ -916,7 +916,7 @@ KResult ProcFSRootDirectory::traverse_as_directory(unsigned fsid, Function(process_id << 36) }; diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 6299afa079..d434b37738 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -44,7 +44,7 @@ static void create_signal_trampoline(); RecursiveSpinlock g_profiling_lock; static Atomic next_pid; -static Singleton> s_processes; +static Singleton> s_processes; READONLY_AFTER_INIT HashMap>* g_modules; READONLY_AFTER_INIT Memory::Region* g_signal_trampoline_region; @@ -55,7 +55,7 @@ MutexProtected& hostname() return *s_hostname; } -MutexProtected& processes() +SpinlockProtected& processes() { return *s_processes; } @@ -86,7 +86,7 @@ UNMAP_AFTER_INIT void Process::initialize() NonnullRefPtrVector Process::all_processes() { NonnullRefPtrVector output; - processes().with_shared([&](const auto& list) { + processes().with([&](const auto& list) { output.ensure_capacity(list.size_slow()); for (const auto& process : list) output.append(NonnullRefPtr(process)); @@ -138,7 +138,7 @@ void Process::register_new(Process& process) { // Note: this is essentially the same like process->ref() RefPtr new_process = process; - processes().with_exclusive([&](auto& list) { + processes().with([&](auto& list) { list.prepend(process); }); } @@ -301,7 +301,7 @@ bool Process::unref() const // NOTE: We need to obtain the process list lock before doing anything, // because otherwise someone might get in between us lowering the // refcount and acquiring the lock. - auto did_hit_zero = processes().with_exclusive([&](auto& list) { + auto did_hit_zero = processes().with([&](auto& list) { auto new_ref_count = deref_base(); if (new_ref_count > 0) return false; @@ -418,7 +418,7 @@ void Process::crash(int signal, FlatPtr ip, bool out_of_memory) RefPtr Process::from_pid(ProcessID pid) { - return processes().with_shared([&](const auto& list) -> RefPtr { + return processes().with([&](const auto& list) -> RefPtr { for (auto& process : list) { if (process.pid() == pid) return &process; @@ -696,7 +696,7 @@ void Process::die() m_threads_for_coredump.append(thread); }); - processes().with_shared([&](const auto& list) { + processes().with([&](const auto& list) { for (auto it = list.begin(); it != list.end();) { auto& process = *it; ++it; diff --git a/Kernel/Process.h b/Kernel/Process.h index c891ee9ff5..71d33f372e 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -815,13 +815,13 @@ static_assert(sizeof(Process) == (PAGE_SIZE * 2)); extern RecursiveSpinlock g_profiling_lock; -MutexProtected& processes(); +SpinlockProtected& processes(); template Callback> inline void Process::for_each(Callback callback) { VERIFY_INTERRUPTS_DISABLED(); - processes().with_shared([&](const auto& list) { + processes().with([&](const auto& list) { for (auto it = list.begin(); it != list.end();) { auto& process = *it; ++it; @@ -835,7 +835,7 @@ template Callback> inline void Process::for_each_child(Callback callback) { ProcessID my_pid = pid(); - processes().with_shared([&](const auto& list) { + processes().with([&](const auto& list) { for (auto it = list.begin(); it != list.end();) { auto& process = *it; ++it; @@ -876,7 +876,7 @@ inline IterationDecision Process::for_each_thread(Callback callback) template Callback> inline void Process::for_each_in_pgrp(ProcessGroupID pgid, Callback callback) { - processes().with_shared([&](const auto& list) { + processes().with([&](const auto& list) { for (auto it = list.begin(); it != list.end();) { auto& process = *it; ++it; diff --git a/Kernel/Syscalls/kill.cpp b/Kernel/Syscalls/kill.cpp index 4033348e94..24339516db 100644 --- a/Kernel/Syscalls/kill.cpp +++ b/Kernel/Syscalls/kill.cpp @@ -65,7 +65,7 @@ KResult Process::do_killall(int signal) KResult error = KSuccess; // Send the signal to all processes we have access to for. - processes().for_each_shared([&](auto& process) { + processes().for_each([&](auto& process) { KResult res = KSuccess; if (process.pid() == pid()) res = do_killself(signal);