summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-09-03 20:39:57 +0200
committerGitHub <noreply@github.com>2020-09-03 20:39:57 +0200
commitba5419b9654607f4c9af6e39dd41031b14ad5621 (patch)
tree3b6df9b77cf1bea0032f0e0e0aa4ed4530c9dc8a /src
parentMerge pull request #4575 from lioncash/async (diff)
parenthle/scheduler: Fix data race in is_context_switch_pending (diff)
downloadyuzu-ba5419b9654607f4c9af6e39dd41031b14ad5621.tar
yuzu-ba5419b9654607f4c9af6e39dd41031b14ad5621.tar.gz
yuzu-ba5419b9654607f4c9af6e39dd41031b14ad5621.tar.bz2
yuzu-ba5419b9654607f4c9af6e39dd41031b14ad5621.tar.lz
yuzu-ba5419b9654607f4c9af6e39dd41031b14ad5621.tar.xz
yuzu-ba5419b9654607f4c9af6e39dd41031b14ad5621.tar.zst
yuzu-ba5419b9654607f4c9af6e39dd41031b14ad5621.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/scheduler.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index a4b234424..5cbd3b912 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -756,7 +756,11 @@ void Scheduler::SwitchToCurrent() {
current_thread = selected_thread;
is_context_switch_pending = false;
}
- while (!is_context_switch_pending) {
+ const auto is_switch_pending = [this] {
+ std::scoped_lock lock{guard};
+ return is_context_switch_pending;
+ };
+ do {
if (current_thread != nullptr && !current_thread->IsHLEThread()) {
current_thread->context_guard.lock();
if (!current_thread->IsRunnable()) {
@@ -775,7 +779,7 @@ void Scheduler::SwitchToCurrent() {
next_context = &idle_thread->GetHostContext();
}
Common::Fiber::YieldTo(switch_fiber, *next_context);
- }
+ } while (!is_switch_pending());
}
}