Kernel: Add WaitQueue::wait_forever and it use it for all infinite waits.

In preparation for marking BlockingResult [[nodiscard]], there are a few
places that perform infinite waits, which we never observe the result of
the wait. Instead of suppressing them, add an alternate function which
returns void when performing and infinite wait.
This commit is contained in:
Brian Gianforcaro 2021-02-14 15:02:14 -08:00 committed by Andreas Kling
parent 4ac286903d
commit ddd79fe2cf
Notes: sideshowbarker 2024-07-18 22:18:29 +09:00
9 changed files with 15 additions and 9 deletions

View file

@ -239,7 +239,7 @@ void SB16::handle_irq(const RegisterState&)
void SB16::wait_for_irq()
{
m_irq_queue.wait_on({}, "SB16");
m_irq_queue.wait_forever("SB16");
disable_irq();
}

View file

@ -74,7 +74,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FIFO::open_direction_blocking(FIFO::Di
if (m_writers == 0) {
locker.unlock();
m_write_open_queue.wait_on({}, "FIFO");
m_write_open_queue.wait_forever("FIFO");
locker.lock();
}
}
@ -84,7 +84,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FIFO::open_direction_blocking(FIFO::Di
if (m_readers == 0) {
locker.unlock();
m_read_open_queue.wait_on({}, "FIFO");
m_read_open_queue.wait_forever("FIFO");
locker.lock();
}
}

View file

@ -127,7 +127,7 @@ void Lock::lock(Mode mode)
}
m_lock.store(false, AK::memory_order_release);
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ {} ({}) waiting...", this, m_name);
m_queue.wait_on({}, m_name);
m_queue.wait_forever(m_name);
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ {} ({}) waited", this, m_name);
}
}

View file

@ -444,7 +444,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload)
sti();
break;
}
m_wait_queue.wait_on({}, "E1000NetworkAdapter");
m_wait_queue.wait_forever("E1000NetworkAdapter");
}
#if E1000_DEBUG
dbgln("E1000: Sent packet, status is now {:#02x}!", (u8)descriptor.status);

View file

@ -392,7 +392,7 @@ void NE2000NetworkAdapter::send_raw(ReadonlyBytes payload)
}
while (in8(REG_RW_COMMAND) & BIT_COMMAND_TXP)
m_wait_queue.wait_on({}, "NE2000NetworkAdapter");
m_wait_queue.wait_forever("NE2000NetworkAdapter");
disable_irq();
size_t packet_size = payload.size();

View file

@ -106,7 +106,7 @@ void NetworkTask_main(void*)
for (;;) {
size_t packet_size = dequeue_packet(buffer, buffer_size, packet_timestamp);
if (!packet_size) {
packet_wait_queue.wait_on({}, "NetworkTask");
packet_wait_queue.wait_forever("NetworkTask");
continue;
}
if (packet_size < sizeof(EthernetFrameHeader)) {

View file

@ -91,7 +91,7 @@ void KernelRng::wait_for_entropy()
ScopedSpinLock lock(get_lock());
if (!resource().is_ready()) {
dbgln("Entropy starvation...");
m_seed_queue.wait_on({}, "KernelRng");
m_seed_queue.wait_forever("KernelRng");
}
}

View file

@ -36,7 +36,7 @@ void FinalizerTask::spawn()
finalizer_thread, "FinalizerTask", [](void*) {
Thread::current()->set_priority(THREAD_PRIORITY_LOW);
for (;;) {
g_finalizer_wait_queue->wait_on({}, "FinalizerTask");
g_finalizer_wait_queue->wait_forever("FinalizerTask");
if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true)
Thread::finalize_dying_threads();

View file

@ -50,6 +50,12 @@ public:
return Thread::current()->block<Thread::QueueBlocker>(timeout, *this, forward<Args>(args)...);
}
template<class... Args>
void wait_forever(Args&&... args)
{
(void)Thread::current()->block<Thread::QueueBlocker>({}, *this, forward<Args>(args)...);
}
protected:
virtual bool should_add_blocker(Thread::Blocker& b, void* data) override;