mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-30 05:08:56 +00:00
Kernel: Add a SpinLock to the WaitQueue
We need to be able to prevent a WaitQueue from being modified by another CPU. So, add a SpinLock to it. Because this pushes some other class over the 64 byte limit, we also need to add another 128-byte bucket to the slab allocator.
This commit is contained in:
@@ -39,13 +39,13 @@ WaitQueue::~WaitQueue()
|
||||
|
||||
void WaitQueue::enqueue(Thread& thread)
|
||||
{
|
||||
ScopedCritical critical;
|
||||
ScopedSpinLock queue_lock(m_lock);
|
||||
m_threads.append(thread);
|
||||
}
|
||||
|
||||
void WaitQueue::wake_one(Atomic<bool>* lock)
|
||||
{
|
||||
ScopedCritical critical;
|
||||
ScopedSpinLock queue_lock(m_lock);
|
||||
if (lock)
|
||||
*lock = false;
|
||||
if (m_threads.is_empty())
|
||||
@@ -57,7 +57,7 @@ void WaitQueue::wake_one(Atomic<bool>* lock)
|
||||
|
||||
void WaitQueue::wake_n(i32 wake_count)
|
||||
{
|
||||
ScopedCritical critical;
|
||||
ScopedSpinLock queue_lock(m_lock);
|
||||
if (m_threads.is_empty())
|
||||
return;
|
||||
|
||||
@@ -72,7 +72,7 @@ void WaitQueue::wake_n(i32 wake_count)
|
||||
|
||||
void WaitQueue::wake_all()
|
||||
{
|
||||
ScopedCritical critical;
|
||||
ScopedSpinLock queue_lock(m_lock);
|
||||
if (m_threads.is_empty())
|
||||
return;
|
||||
while (!m_threads.is_empty())
|
||||
@@ -82,7 +82,7 @@ void WaitQueue::wake_all()
|
||||
|
||||
void WaitQueue::clear()
|
||||
{
|
||||
ScopedCritical critical;
|
||||
ScopedSpinLock queue_lock(m_lock);
|
||||
m_threads.clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user