1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:27:35 +00:00

Kernel: Fix kernel panic when blocking on the process' big lock

Another thread might end up marking the blocking thread as holding
the lock before it gets a chance to finish invoking the scheduler.
This commit is contained in:
Gunnar Beutner 2021-08-10 21:20:45 +02:00 committed by Andreas Kling
parent 309a20c014
commit 3322efd4cd
3 changed files with 17 additions and 8 deletions

View file

@ -836,7 +836,7 @@ public:
while (state() == Thread::Stopped) {
lock.unlock();
// We shouldn't be holding the big lock here
yield_assuming_not_holding_big_lock();
yield_without_releasing_big_lock();
lock.lock();
}
}
@ -922,7 +922,7 @@ public:
// Yield to the scheduler, and wait for us to resume unblocked.
VERIFY(!g_scheduler_lock.own_lock());
VERIFY(Processor::in_critical());
yield_assuming_not_holding_big_lock();
yield_without_releasing_big_lock();
VERIFY(Processor::in_critical());
ScopedSpinLock block_lock2(m_block_lock);
@ -1371,7 +1371,13 @@ private:
bool m_is_profiling_suppressed { false };
void yield_and_release_relock_big_lock();
void yield_assuming_not_holding_big_lock();
enum class VerifyLockNotHeld {
Yes,
No
};
void yield_without_releasing_big_lock(VerifyLockNotHeld verify_lock_not_held = VerifyLockNotHeld::Yes);
void drop_thread_count(bool);
public: