mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +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:
@@ -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 };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user