1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00

Kernel: Snooze the NetworkTask until there are incoming packets to process.

This is accomplished using a new Alarm class and a BlockedSnoozing state.
Basically, you call Process::snooze_until(some_alarm) and then the scheduler
won't wake up the process until some_alarm.is_ringing() returns true.
This commit is contained in:
Andreas Kling 2019-03-20 17:09:46 +01:00
parent 93aa4d581d
commit bc1da7f1fd
6 changed files with 51 additions and 6 deletions

View file

@ -25,6 +25,7 @@ NetworkAdapter* NetworkAdapter::from_ipv4_address(const IPv4Address& address)
}
NetworkAdapter::NetworkAdapter()
: m_packet_queue_alarm(*this)
{
// FIXME: I wanna lock :(
ASSERT_INTERRUPTS_DISABLED();
@ -90,3 +91,8 @@ void NetworkAdapter::set_ipv4_address(const IPv4Address& address)
{
m_ipv4_address = address;
}
bool PacketQueueAlarm::is_ringing() const
{
return m_adapter.has_queued_packets();
}