diff options
author | Tom <tomut@yahoo.com> | 2020-06-27 13:42:28 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-01 12:07:01 +0200 |
commit | fb41d89384cb5bbdf602ae41ae7e038fb48a34ce (patch) | |
tree | 21f97ea745e1eb15d88cc8e9ccd7b1d4b15a30f3 /Kernel/Tasks | |
parent | 10407061d21abcfbc0c63e37314f4ae3938e3e25 (diff) | |
download | serenity-fb41d89384cb5bbdf602ae41ae7e038fb48a34ce.zip |
Kernel: Implement software context switching and Processor structure
Moving certain globals into a new Processor structure for
each CPU allows us to eventually run an instance of the
scheduler on each CPU.
Diffstat (limited to 'Kernel/Tasks')
-rw-r--r-- | Kernel/Tasks/FinalizerTask.cpp | 14 | ||||
-rw-r--r-- | Kernel/Tasks/SyncTask.cpp | 1 |
2 files changed, 7 insertions, 8 deletions
diff --git a/Kernel/Tasks/FinalizerTask.cpp b/Kernel/Tasks/FinalizerTask.cpp index 4b1f1ef738..554f2149c9 100644 --- a/Kernel/Tasks/FinalizerTask.cpp +++ b/Kernel/Tasks/FinalizerTask.cpp @@ -34,14 +34,12 @@ void FinalizerTask::spawn() Process::create_kernel_process(g_finalizer, "FinalizerTask", [] { Thread::current->set_priority(THREAD_PRIORITY_LOW); for (;;) { - { - InterruptDisabler disabler; - if (!g_finalizer_has_work) - Thread::current->wait_on(*g_finalizer_wait_queue); - ASSERT(g_finalizer_has_work); - g_finalizer_has_work = false; - } - Thread::finalize_dying_threads(); + dbg() << "Finalizer task is running"; + Thread::current->wait_on(*g_finalizer_wait_queue); + + bool expected = true; + if (g_finalizer_has_work.compare_exchange_strong(expected, false, AK::MemoryOrder::memory_order_acq_rel)) + Thread::finalize_dying_threads(); } }); } diff --git a/Kernel/Tasks/SyncTask.cpp b/Kernel/Tasks/SyncTask.cpp index f4d1dffafd..33f18c8b3a 100644 --- a/Kernel/Tasks/SyncTask.cpp +++ b/Kernel/Tasks/SyncTask.cpp @@ -35,6 +35,7 @@ void SyncTask::spawn() { Thread* syncd_thread = nullptr; Process::create_kernel_process(syncd_thread, "SyncTask", [] { + dbg() << "SyncTask is running"; for (;;) { VFS::the().sync(); Thread::current->sleep(1 * TimeManagement::the().ticks_per_second()); |