mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel: Rename functions to be less confusing
Thread::yield_and_release_relock_big_lock releases the big lock, yields and then relocks the big lock. Thread::yield_assuming_not_holding_big_lock yields assuming the big lock is not being held.
This commit is contained in:
parent
0536a4ff41
commit
704e1c2e3d
Notes:
sideshowbarker
2024-07-18 08:55:28 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/704e1c2e3d4 Pull-request: https://github.com/SerenityOS/serenity/pull/8791 Issue: https://github.com/SerenityOS/serenity/issues/8787
3 changed files with 12 additions and 11 deletions
|
@ -11,7 +11,7 @@ namespace Kernel {
|
||||||
KResultOr<FlatPtr> Process::sys$yield()
|
KResultOr<FlatPtr> Process::sys$yield()
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(stdio);
|
||||||
Thread::current()->yield_without_holding_big_lock();
|
Thread::current()->yield_and_release_relock_big_lock();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,9 +219,9 @@ void Thread::block(Kernel::Lock& lock, ScopedSpinLock<SpinLock<u8>>& lock_lock,
|
||||||
if (&lock != &big_lock && big_lock.own_lock()) {
|
if (&lock != &big_lock && big_lock.own_lock()) {
|
||||||
// We're locking another lock and already hold the big lock...
|
// We're locking another lock and already hold the big lock...
|
||||||
// We need to release the big lock
|
// We need to release the big lock
|
||||||
yield_without_holding_big_lock();
|
yield_and_release_relock_big_lock();
|
||||||
} else {
|
} else {
|
||||||
yield_while_not_holding_big_lock();
|
yield_assuming_not_holding_big_lock();
|
||||||
}
|
}
|
||||||
VERIFY(Processor::current().in_critical());
|
VERIFY(Processor::current().in_critical());
|
||||||
|
|
||||||
|
@ -414,9 +414,10 @@ void Thread::exit(void* exit_value)
|
||||||
die_if_needed();
|
die_if_needed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::yield_while_not_holding_big_lock()
|
void Thread::yield_assuming_not_holding_big_lock()
|
||||||
{
|
{
|
||||||
VERIFY(!g_scheduler_lock.own_lock());
|
VERIFY(!g_scheduler_lock.own_lock());
|
||||||
|
VERIFY(!process().big_lock().own_lock());
|
||||||
// Disable interrupts here. This ensures we don't accidentally switch contexts twice
|
// Disable interrupts here. This ensures we don't accidentally switch contexts twice
|
||||||
InterruptDisabler disable;
|
InterruptDisabler disable;
|
||||||
Scheduler::yield(); // flag a switch
|
Scheduler::yield(); // flag a switch
|
||||||
|
@ -426,7 +427,7 @@ void Thread::yield_while_not_holding_big_lock()
|
||||||
Processor::current().restore_critical(prev_crit, prev_flags);
|
Processor::current().restore_critical(prev_crit, prev_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::yield_without_holding_big_lock()
|
void Thread::yield_and_release_relock_big_lock()
|
||||||
{
|
{
|
||||||
VERIFY(!g_scheduler_lock.own_lock());
|
VERIFY(!g_scheduler_lock.own_lock());
|
||||||
// Disable interrupts here. This ensures we don't accidentally switch contexts twice
|
// Disable interrupts here. This ensures we don't accidentally switch contexts twice
|
||||||
|
@ -594,7 +595,7 @@ void Thread::check_dispatch_pending_signal()
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case DispatchSignalResult::Yield:
|
case DispatchSignalResult::Yield:
|
||||||
yield_while_not_holding_big_lock();
|
yield_assuming_not_holding_big_lock();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -701,7 +702,7 @@ void Thread::send_urgent_signal_to_self(u8 signal)
|
||||||
result = dispatch_signal(signal);
|
result = dispatch_signal(signal);
|
||||||
}
|
}
|
||||||
if (result == DispatchSignalResult::Yield)
|
if (result == DispatchSignalResult::Yield)
|
||||||
yield_without_holding_big_lock();
|
yield_and_release_relock_big_lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatchSignalResult Thread::dispatch_one_pending_signal()
|
DispatchSignalResult Thread::dispatch_one_pending_signal()
|
||||||
|
|
|
@ -819,7 +819,7 @@ public:
|
||||||
while (state() == Thread::Stopped) {
|
while (state() == Thread::Stopped) {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
// We shouldn't be holding the big lock here
|
// We shouldn't be holding the big lock here
|
||||||
yield_while_not_holding_big_lock();
|
yield_assuming_not_holding_big_lock();
|
||||||
lock.lock();
|
lock.lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -905,7 +905,7 @@ public:
|
||||||
// Yield to the scheduler, and wait for us to resume unblocked.
|
// Yield to the scheduler, and wait for us to resume unblocked.
|
||||||
VERIFY(!g_scheduler_lock.own_lock());
|
VERIFY(!g_scheduler_lock.own_lock());
|
||||||
VERIFY(Processor::current().in_critical());
|
VERIFY(Processor::current().in_critical());
|
||||||
yield_while_not_holding_big_lock();
|
yield_assuming_not_holding_big_lock();
|
||||||
VERIFY(Processor::current().in_critical());
|
VERIFY(Processor::current().in_critical());
|
||||||
|
|
||||||
ScopedSpinLock block_lock2(m_block_lock);
|
ScopedSpinLock block_lock2(m_block_lock);
|
||||||
|
@ -1341,8 +1341,8 @@ private:
|
||||||
|
|
||||||
bool m_is_profiling_suppressed { false };
|
bool m_is_profiling_suppressed { false };
|
||||||
|
|
||||||
void yield_without_holding_big_lock();
|
void yield_and_release_relock_big_lock();
|
||||||
void yield_while_not_holding_big_lock();
|
void yield_assuming_not_holding_big_lock();
|
||||||
void drop_thread_count(bool);
|
void drop_thread_count(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue