1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +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

@ -14,6 +14,7 @@
#include <AK/Weakable.h>
#include <Kernel/Lock.h>
class Alarm;
class FileDescriptor;
class PageDirectory;
class Region;
@ -78,6 +79,7 @@ public:
BlockedSelect,
BlockedConnect,
BlockedReceive,
BlockedSnoozing,
};
enum Priority {
@ -139,6 +141,8 @@ public:
void set_wakeup_time(dword t) { m_wakeup_time = t; }
dword wakeup_time() const { return m_wakeup_time; }
void snooze_until(Alarm&);
template<typename Callback> static void for_each(Callback);
template<typename Callback> static void for_each_in_pgrp(pid_t, Callback);
template<typename Callback> static void for_each_in_state(State, Callback);
@ -382,6 +386,7 @@ private:
dword m_pending_signals { 0 };
dword m_signal_mask { 0 };
RetainPtr<Socket> m_blocked_socket;
Alarm* m_snoozing_alarm { nullptr };
byte m_termination_status { 0 };
byte m_termination_signal { 0 };