1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 17:28:10 +00:00

Kernel: Pass trampolines instead of lambdas to create_kernel_process

With -Og, all calls to create_kernel_process were triggering -Wnonnull
when creating these lambdas that get implicitly converted to function
pointers. A different design of create_kernel_process to use
AK::Function instead might avoid this awkward behavior.
This commit is contained in:
Andrew Kaster 2021-05-23 13:45:58 -06:00 committed by Andreas Kling
parent 6459c5a713
commit 86e3010043
2 changed files with 22 additions and 19 deletions

View file

@ -9,20 +9,22 @@
namespace Kernel {
static void finalizer_task(void*)
{
Thread::current()->set_priority(THREAD_PRIORITY_LOW);
for (;;) {
g_finalizer_wait_queue->wait_forever("FinalizerTask");
if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true)
Thread::finalize_dying_threads();
}
};
void FinalizerTask::spawn()
{
RefPtr<Thread> finalizer_thread;
Process::create_kernel_process(
finalizer_thread, "FinalizerTask", [](void*) {
Thread::current()->set_priority(THREAD_PRIORITY_LOW);
for (;;) {
g_finalizer_wait_queue->wait_forever("FinalizerTask");
if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true)
Thread::finalize_dying_threads();
}
},
nullptr);
auto finalizer_process = Process::create_kernel_process(finalizer_thread, "FinalizerTask", finalizer_task, nullptr);
VERIFY(finalizer_process);
g_finalizer = finalizer_thread;
}