mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 00:25:07 +00:00
Kernel/Tasks: Allow Kernel processes to be shut down
Since we never check a kernel process's state like a userland process, it's possible for a kernel process to ignore the fact that someone is trying to kill it, and continue running. This is not desireable if we want to properly shutdown all processes, including Kernel ones.
This commit is contained in:
parent
8940552d1d
commit
021fb3ea05
7 changed files with 22 additions and 9 deletions
|
@ -16,7 +16,7 @@ static constexpr StringView finalizer_task_name = "Finalizer Task"sv;
|
|||
static void finalizer_task(void*)
|
||||
{
|
||||
Thread::current()->set_priority(THREAD_PRIORITY_LOW);
|
||||
for (;;) {
|
||||
while (!Process::current().is_dying()) {
|
||||
// The order of this if-else is important: We want to continue trying to finalize the threads in case
|
||||
// Thread::finalize_dying_threads set g_finalizer_has_work back to true due to OOM conditions
|
||||
if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true)
|
||||
|
@ -24,6 +24,8 @@ static void finalizer_task(void*)
|
|||
else
|
||||
g_finalizer_wait_queue->wait_forever(finalizer_task_name);
|
||||
}
|
||||
Process::current().sys$exit(0);
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void FinalizerTask::spawn()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue