mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-07 17:15:26 +00:00
Kernel: Fix Lock racing to the WaitQueue
There was a time window between releasing Lock::m_lock and calling into the lock's WaitQueue where someone else could take m_lock and bring two threads into a deadlock situation. Fix this issue by holding Lock::m_lock until interrupts are disabled by either Thread::wait_on() or WaitQueue::wake_one().
This commit is contained in:
@@ -15,9 +15,11 @@ void WaitQueue::enqueue(Thread& thread)
|
||||
m_threads.append(thread);
|
||||
}
|
||||
|
||||
void WaitQueue::wake_one()
|
||||
void WaitQueue::wake_one(Atomic<bool>* lock)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
if (lock)
|
||||
*lock = false;
|
||||
if (m_threads.is_empty())
|
||||
return;
|
||||
if (auto* thread = m_threads.take_first())
|
||||
|
||||
Reference in New Issue
Block a user