1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 01:17:36 +00:00

Kernel: Enhance WaitQueue to remember pending wakes

If WaitQueue::wake_all, WaitQueue::wake_one, or WaitQueue::wake_n
is called but nobody is currently waiting, we should remember that
fact and prevent someone from waiting after such a request. This
solves a race condition where the Finalizer thread is notified
to finalize a thread, but it is not (yet) waiting on this queue.

Fixes #2693
This commit is contained in:
Tom 2020-07-05 15:46:51 -06:00 committed by Andreas Kling
parent 2a82a25fec
commit 9725bda63e
5 changed files with 93 additions and 27 deletions

View file

@ -38,9 +38,9 @@ public:
WaitQueue();
~WaitQueue();
void enqueue(Thread&);
bool enqueue(Thread&);
void wake_one(Atomic<bool>* lock = nullptr);
void wake_n(i32 wake_count);
void wake_n(u32 wake_count);
void wake_all();
void clear();
@ -48,6 +48,7 @@ private:
typedef IntrusiveList<Thread, &Thread::m_wait_queue_node> ThreadList;
ThreadList m_threads;
SpinLock<u32> m_lock;
bool m_wake_requested { false };
};
}