mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-02 22:55:23 +00: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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user