diff options
author | Tom <tomut@yahoo.com> | 2020-11-29 16:05:27 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-30 13:17:02 +0100 |
commit | 046d6855f5e8a5039b319a47c3018a16d4c2f960 (patch) | |
tree | 9021179989bea74ec7d14a4c30d77eb2b2609f23 /Kernel/Tasks/FinalizerTask.cpp | |
parent | 6a620562cc7298c2f591a06817ff560c9ef1deac (diff) | |
download | serenity-046d6855f5e8a5039b319a47c3018a16d4c2f960.zip |
Kernel: Move block condition evaluation out of the Scheduler
This makes the Scheduler a lot leaner by not having to evaluate
block conditions every time it is invoked. Instead evaluate them as
the states change, and unblock threads at that point.
This also implements some more waitid/waitpid/wait features and
behavior. For example, WUNTRACED and WNOWAIT are now supported. And
wait will now not return EINTR when SIGCHLD is delivered at the
same time.
Diffstat (limited to 'Kernel/Tasks/FinalizerTask.cpp')
-rw-r--r-- | Kernel/Tasks/FinalizerTask.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Kernel/Tasks/FinalizerTask.cpp b/Kernel/Tasks/FinalizerTask.cpp index f05d573a7f..8b2574b62c 100644 --- a/Kernel/Tasks/FinalizerTask.cpp +++ b/Kernel/Tasks/FinalizerTask.cpp @@ -32,16 +32,17 @@ namespace Kernel { void FinalizerTask::spawn() { RefPtr<Thread> finalizer_thread; - Process::create_kernel_process(finalizer_thread, "FinalizerTask", [](void*) { - Thread::current()->set_priority(THREAD_PRIORITY_LOW); - for (;;) { - Thread::current()->wait_on(*g_finalizer_wait_queue, "FinalizerTask"); + Process::create_kernel_process( + finalizer_thread, "FinalizerTask", [](void*) { + Thread::current()->set_priority(THREAD_PRIORITY_LOW); + for (;;) { + Thread::current()->wait_on(*g_finalizer_wait_queue, "FinalizerTask"); - bool expected = true; - if (g_finalizer_has_work.compare_exchange_strong(expected, false, AK::MemoryOrder::memory_order_acq_rel)) - Thread::finalize_dying_threads(); - } - }, nullptr); + if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true) + Thread::finalize_dying_threads(); + } + }, + nullptr); g_finalizer = finalizer_thread; } |