mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:48:12 +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:
parent
93aa4d581d
commit
bc1da7f1fd
6 changed files with 51 additions and 6 deletions
|
@ -1735,6 +1735,13 @@ void Process::unblock()
|
|||
m_state = Process::Runnable;
|
||||
}
|
||||
|
||||
void Process::snooze_until(Alarm& alarm)
|
||||
{
|
||||
m_snoozing_alarm = &alarm;
|
||||
block(Process::BlockedSnoozing);
|
||||
Scheduler::yield();
|
||||
}
|
||||
|
||||
void Process::block(Process::State new_state)
|
||||
{
|
||||
if (state() != Process::Running) {
|
||||
|
@ -2871,6 +2878,7 @@ const char* to_string(Process::State state)
|
|||
case Process::BlockedConnect: return "Connect";
|
||||
case Process::BlockedReceive: return "Receive";
|
||||
case Process::BeingInspected: return "Inspect";
|
||||
case Process::BlockedSnoozing: return "Snoozing";
|
||||
}
|
||||
kprintf("to_string(Process::State): Invalid state: %u\n", state);
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue