mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:58:13 +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:
parent
788b2d64c6
commit
49f5069b76
3 changed files with 13 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue