1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 16:45:09 +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

@ -34,16 +34,16 @@ Lockable<HashMap<IPv4Address, MACAddress>>& arp_table()
void NetworkTask_main()
{
auto* e1000_ptr = E1000NetworkAdapter::the();
ASSERT(e1000_ptr);
auto& e1000 = *e1000_ptr;
e1000.set_ipv4_address(IPv4Address(192, 168, 5, 2));
auto* adapter_ptr = E1000NetworkAdapter::the();
ASSERT(adapter_ptr);
auto& adapter = *adapter_ptr;
adapter.set_ipv4_address(IPv4Address(192, 168, 5, 2));
kprintf("NetworkTask: Enter main loop.\n");
for (;;) {
auto packet = e1000.dequeue_packet();
auto packet = adapter.dequeue_packet();
if (packet.is_null()) {
sleep(100);
current->snooze_until(adapter.packet_queue_alarm());
continue;
}
if (packet.size() < (int)(sizeof(EthernetFrameHeader))) {