summaryrefslogtreecommitdiff
path: root/Kernel/init.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-06 18:45:21 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-06 18:45:21 +0100
commit6cba80510e2d5310c6ec545e93ab85b18bc7e3c4 (patch)
treec388a94283c62a7bb6b6350aa5f99f129f118bad /Kernel/init.cpp
parente05237485c50c309a0f79c000418d34e5278eebe (diff)
downloadserenity-6cba80510e2d5310c6ec545e93ab85b18bc7e3c4.zip
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.
Diffstat (limited to 'Kernel/init.cpp')
-rw-r--r--Kernel/init.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index 47f0018357..545d94357d 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -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();