summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-03-07 01:20:36 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2020-06-27 17:35:31 +0200
commit3de33348e41ab824eb13f202eccc29d5be2a6d42 (patch)
tree1ba88c8268decee6116289f58944712c26073941 /src
parentScheduler: Correct assert. (diff)
downloadyuzu-3de33348e41ab824eb13f202eccc29d5be2a6d42.tar
yuzu-3de33348e41ab824eb13f202eccc29d5be2a6d42.tar.gz
yuzu-3de33348e41ab824eb13f202eccc29d5be2a6d42.tar.bz2
yuzu-3de33348e41ab824eb13f202eccc29d5be2a6d42.tar.lz
yuzu-3de33348e41ab824eb13f202eccc29d5be2a6d42.tar.xz
yuzu-3de33348e41ab824eb13f202eccc29d5be2a6d42.tar.zst
yuzu-3de33348e41ab824eb13f202eccc29d5be2a6d42.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/scheduler.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index 4e2a5adf3..74d3731fc 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -604,7 +604,6 @@ void Scheduler::SwitchContextStep2() {
if (new_thread) {
auto& cpu_core = system.ArmInterface(core_id);
- new_thread->context_guard.lock();
cpu_core.Lock();
ASSERT_MSG(new_thread->GetSchedulingStatus() == ThreadSchedStatus::Runnable,
"Thread must be runnable.");
@@ -685,13 +684,24 @@ void Scheduler::OnSwitch(void* this_scheduler) {
void Scheduler::SwitchToCurrent() {
while (true) {
- std::shared_ptr<Common::Fiber> next_context;
- if (current_thread != nullptr) {
- next_context = current_thread->GetHostContext();
- } else {
- next_context = idle_thread->GetHostContext();
+ guard.lock();
+ selected_thread = selected_thread_set;
+ current_thread = selected_thread;
+ guard.unlock();
+ while (!is_context_switch_pending) {
+ current_thread->context_guard.lock();
+ if (current_thread->GetSchedulingStatus() != ThreadSchedStatus::Runnable) {
+ current_thread->context_guard.unlock();
+ break;
+ }
+ std::shared_ptr<Common::Fiber> next_context;
+ if (current_thread != nullptr) {
+ next_context = current_thread->GetHostContext();
+ } else {
+ next_context = idle_thread->GetHostContext();
+ }
+ Common::Fiber::YieldTo(switch_fiber, next_context);
}
- Common::Fiber::YieldTo(switch_fiber, next_context);
}
}