summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2021-07-08 19:37:36 -0600
committerAndreas Kling <kling@serenityos.org>2021-07-12 11:27:18 +0200
commit6938be00f1c2c87a83a173cca0c8a7c78ac88a94 (patch)
tree5adaae5d89177c67933468026000fc80f6b9991b /Kernel/Process.cpp
parentc2792212f42f8ab864201be760fc9a0263240bab (diff)
downloadserenity-6938be00f1c2c87a83a173cca0c8a7c78ac88a94.zip
Kernel: Initialize threading and process management earlier
This re-arranges the order of how things are initialized so that we try to initialize process and thread management earlier. This is neccessary because a lot of the code uses the Lock class, which really needs to have a running scheduler in place so that we can properly preempt. This also enables us to potentially initialize some things in parallel.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 5c7448f56b..5c6b233a50 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -133,8 +133,10 @@ void Process::register_new(Process& process)
{
// Note: this is essentially the same like process->ref()
RefPtr<Process> new_process = process;
- ScopedSpinLock lock(g_processes_lock);
- g_processes->prepend(process);
+ {
+ ScopedSpinLock lock(g_processes_lock);
+ g_processes->prepend(process);
+ }
ProcFSComponentRegistry::the().register_new_process(process);
}
@@ -180,7 +182,7 @@ RefPtr<Process> Process::create_user_process(RefPtr<Thread>& first_thread, const
return process;
}
-RefPtr<Process> Process::create_kernel_process(RefPtr<Thread>& first_thread, String&& name, void (*entry)(void*), void* entry_data, u32 affinity)
+RefPtr<Process> Process::create_kernel_process(RefPtr<Thread>& first_thread, String&& name, void (*entry)(void*), void* entry_data, u32 affinity, RegisterProcess do_register)
{
auto process = Process::create(first_thread, move(name), (uid_t)0, (gid_t)0, ProcessID(0), true);
if (!first_thread || !process)
@@ -193,9 +195,8 @@ RefPtr<Process> Process::create_kernel_process(RefPtr<Thread>& first_thread, Str
first_thread->regs().rdi = FlatPtr(entry_data); // entry function argument is expected to be in regs.rdi
#endif
- if (process->pid() != 0) {
+ if (do_register == RegisterProcess::Yes)
register_new(*process);
- }
ScopedSpinLock lock(g_scheduler_lock);
first_thread->set_affinity(affinity);