1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-30 05:42:06 +00:00

Kernel: Fix a few deadlocks with Thread::m_lock and g_scheduler_lock

g_scheduler_lock cannot safely be acquired after Thread::m_lock
because another processor may already hold g_scheduler_lock and wait
for the same Thread::m_lock.
This commit is contained in:
Tom 2020-10-25 20:22:59 -06:00 committed by Andreas Kling
parent 8c764319ad
commit 1e2e3eed62
6 changed files with 55 additions and 37 deletions

View file

@ -322,6 +322,7 @@ NonnullRefPtr<Process> Process::create_kernel_process(RefPtr<Thread>& first_thre
process->ref();
}
ScopedSpinLock lock(g_scheduler_lock);
first_thread->set_affinity(affinity);
first_thread->set_state(Thread::State::Runnable);
return process;
@ -781,6 +782,7 @@ RefPtr<Thread> Process::create_kernel_thread(void (*entry)(), u32 priority, cons
auto& tss = thread->tss();
tss.eip = (FlatPtr)entry;
ScopedSpinLock lock(g_scheduler_lock);
thread->set_state(Thread::State::Runnable);
return thread;
}