From d24014358883987d7ebdafc4863a7bc36addfa1b Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Wed, 13 May 2020 14:17:34 -0400 Subject: Kernel: Correct Host Context on Threads and Scheduler. --- src/core/hle/kernel/scheduler.cpp | 16 ++++++++-------- src/core/hle/kernel/scheduler.h | 2 +- src/core/hle/kernel/thread.cpp | 2 +- src/core/hle/kernel/thread.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index 43c924fa0..61b8a396a 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp @@ -736,15 +736,15 @@ void Scheduler::SwitchContext() { previous_thread->context_guard.unlock(); } - std::shared_ptr old_context; + std::shared_ptr* old_context; if (previous_thread != nullptr) { - old_context = previous_thread->GetHostContext(); + old_context = &previous_thread->GetHostContext(); } else { - old_context = idle_thread->GetHostContext(); + old_context = &idle_thread->GetHostContext(); } guard.unlock(); - Common::Fiber::YieldTo(old_context, switch_fiber); + Common::Fiber::YieldTo(*old_context, switch_fiber); /// When a thread wakes up, the scheduler may have changed to other in another core. auto& next_scheduler = system.Kernel().CurrentScheduler(); next_scheduler.SwitchContextStep2(); @@ -774,13 +774,13 @@ void Scheduler::SwitchToCurrent() { break; } } - std::shared_ptr next_context; + std::shared_ptr* next_context; if (current_thread != nullptr) { - next_context = current_thread->GetHostContext(); + next_context = ¤t_thread->GetHostContext(); } else { - next_context = idle_thread->GetHostContext(); + next_context = &idle_thread->GetHostContext(); } - Common::Fiber::YieldTo(switch_fiber, next_context); + Common::Fiber::YieldTo(switch_fiber, *next_context); } } } diff --git a/src/core/hle/kernel/scheduler.h b/src/core/hle/kernel/scheduler.h index 10dc4b832..348107160 100644 --- a/src/core/hle/kernel/scheduler.h +++ b/src/core/hle/kernel/scheduler.h @@ -236,7 +236,7 @@ public: void OnThreadStart(); - std::shared_ptr ControlContext() { + std::shared_ptr& ControlContext() { return switch_fiber; } diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index fba2a9c85..2b1092697 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -150,7 +150,7 @@ static void ResetThreadContext64(Core::ARM_Interface::ThreadContext64& context, context.fpcr = 0; } -std::shared_ptr Thread::GetHostContext() const { +std::shared_ptr& Thread::GetHostContext() { return host_context; } diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 3ae0df6ef..c0342c462 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -342,7 +342,7 @@ public: was_running = value; } - std::shared_ptr GetHostContext() const; + std::shared_ptr& GetHostContext(); ThreadStatus GetStatus() const { return status; -- cgit v1.2.3