1
Fork 0
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:
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

@ -4,6 +4,7 @@
#include "RTC.h"
#include "i8253.h"
#include <AK/TemporaryChange.h>
#include <Kernel/Alarm.h>
//#define LOG_EVERY_CONTEXT_SWITCH
//#define SCHEDULER_DEBUG
@ -136,6 +137,14 @@ bool Scheduler::pick_next()
return true;
}
if (process.state() == Process::BlockedSnoozing) {
if (process.m_snoozing_alarm->is_ringing()) {
process.m_snoozing_alarm = nullptr;
process.unblock();
}
return true;
}
if (process.state() == Process::Skip1SchedulerPass) {
process.set_state(Process::Skip0SchedulerPasses);
return true;