summaryrefslogtreecommitdiff
path: root/Kernel/NetworkAdapter.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-20 17:09:46 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-20 17:09:46 +0100
commitbc1da7f1fd2e366d290db4b33f07b9806d2a6932 (patch)
tree8b72a3606893dd69113fd47fe97c47c2abdd1907 /Kernel/NetworkAdapter.cpp
parent93aa4d581d98155e7f49880ba600bb32acd2659f (diff)
downloadserenity-bc1da7f1fd2e366d290db4b33f07b9806d2a6932.zip
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.
Diffstat (limited to 'Kernel/NetworkAdapter.cpp')
-rw-r--r--Kernel/NetworkAdapter.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Kernel/NetworkAdapter.cpp b/Kernel/NetworkAdapter.cpp
index fb09272a98..2188988b66 100644
--- a/Kernel/NetworkAdapter.cpp
+++ b/Kernel/NetworkAdapter.cpp
@@ -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();
+}