1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

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.
This commit is contained in:
Tom 2021-07-08 19:37:36 -06:00 committed by Andreas Kling
parent c2792212f4
commit 6938be00f1
4 changed files with 45 additions and 33 deletions

View file

@ -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);