1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 05:37:35 +00:00

Kernel: Add a Finalizer process to take care of dying processes.

Instead of processes themselves getting scheduled to finish dying,
let's have a Finalizer process that wakes up whenever someone is dying.
This way we can do all kinds of lock-taking in process cleanup without
risking reentering the scheduler.
This commit is contained in:
Andreas Kling 2019-02-06 18:45:21 +01:00
parent e05237485c
commit 6cba80510e
5 changed files with 59 additions and 23 deletions

View file

@ -187,6 +187,14 @@ void init()
sleep(10 * TICKS_PER_SECOND);
}
});
Process::create_kernel_process("Finalizer", [] {
g_finalizer = current;
for (;;) {
Process::finalize_dying_processes();
current->block(Process::BlockedLurking);
Scheduler::yield();
}
});
Scheduler::pick_next();