mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 10:01:50 +01:00
Don't block while inserting paused threads
Blocking while inserting a paused thread can lead to deadlocks where the inserting thread later resumes the paused thread. Co-authored-by: Billy Laws <blaws05@gmail.com>
This commit is contained in:
parent
643f4cf864
commit
6645692288
@ -91,9 +91,9 @@ namespace skyline::kernel {
|
||||
std::unique_lock lock{core.mutex};
|
||||
|
||||
if (thread->isPaused) {
|
||||
// We cannot insert a thread that is paused, so we need to wait until it has been resumed
|
||||
thread->insertThreadOnResume = false;
|
||||
thread->scheduleCondition.wait(lock, [&]() { return !thread->isPaused; });
|
||||
// We cannot insert a thread that is paused, so we just let the resuming thread insert it
|
||||
thread->insertThreadOnResume = true;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -87,6 +87,7 @@ namespace skyline {
|
||||
|
||||
/**
|
||||
* @brief Inserts the specified thread into the scheduler queue at the appropriate location based on its priority
|
||||
* @note This is a non-blocking operation when the thread is paused, the thread will only be inserted when it is resumed
|
||||
*/
|
||||
void InsertThread(const std::shared_ptr<type::KThread> &thread);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user