mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 10:01:13 +09:00
Kernel: Fix some problems with Thread::wait_on and Lock
This changes the Thread::wait_on function to not enable interrupts upon leaving, which caused some problems with page fault handlers and in other situations. It may now be called from critical sections, with interrupts enabled or disabled, and returns to the same state. This also requires some fixes to Lock. To aid debugging, a new define LOCK_DEBUG is added that enables checking for Lock leaks upon finalization of a Thread.
This commit is contained in:
parent
9e32d79e02
commit
78f1b5e359
Notes:
sideshowbarker
2024-07-19 01:08:28 +09:00
Author: https://github.com/tomuta
Commit: 78f1b5e359
Pull-request: https://github.com/SerenityOS/serenity/pull/4281
10 changed files with 178 additions and 83 deletions
|
@ -511,6 +511,21 @@ void Scheduler::invoke_async()
|
|||
pick_next();
|
||||
}
|
||||
|
||||
void Scheduler::yield_from_critical()
|
||||
{
|
||||
auto& proc = Processor::current();
|
||||
ASSERT(proc.in_critical());
|
||||
ASSERT(!proc.in_irq());
|
||||
|
||||
yield(); // Flag a context switch
|
||||
|
||||
u32 prev_flags;
|
||||
u32 prev_crit = Processor::current().clear_critical(prev_flags, false);
|
||||
|
||||
// Note, we may now be on a different CPU!
|
||||
Processor::current().restore_critical(prev_crit, prev_flags);
|
||||
}
|
||||
|
||||
void Scheduler::notify_finalizer()
|
||||
{
|
||||
if (g_finalizer_has_work.exchange(true, AK::MemoryOrder::memory_order_acq_rel) == false)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue