From 2c56e94702e897c609711d82057d8267d8f4d0b3 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 16 Jun 2022 10:35:52 -0400 Subject: kernel: make current thread pointer thread local --- src/core/hle/kernel/k_process.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/core/hle/kernel/k_process.cpp') diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index cb84c20e3..b477c6e55 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp @@ -176,7 +176,8 @@ void KProcess::PinCurrentThread(s32 core_id) { ASSERT(kernel.GlobalSchedulerContext().IsLocked()); // Get the current thread. - KThread* cur_thread = kernel.Scheduler(static_cast(core_id)).GetCurrentThread(); + KThread* cur_thread = + kernel.Scheduler(static_cast(core_id)).GetSchedulerCurrentThread(); // If the thread isn't terminated, pin it. if (!cur_thread->IsTerminationRequested()) { @@ -193,7 +194,8 @@ void KProcess::UnpinCurrentThread(s32 core_id) { ASSERT(kernel.GlobalSchedulerContext().IsLocked()); // Get the current thread. - KThread* cur_thread = kernel.Scheduler(static_cast(core_id)).GetCurrentThread(); + KThread* cur_thread = + kernel.Scheduler(static_cast(core_id)).GetSchedulerCurrentThread(); // Unpin it. cur_thread->Unpin(); @@ -420,11 +422,11 @@ void KProcess::PrepareForTermination() { ChangeStatus(ProcessStatus::Exiting); const auto stop_threads = [this](const std::vector& in_thread_list) { - for (auto& thread : in_thread_list) { + for (auto* thread : in_thread_list) { if (thread->GetOwnerProcess() != this) continue; - if (thread == kernel.CurrentScheduler()->GetCurrentThread()) + if (thread == GetCurrentThreadPointer(kernel)) continue; // TODO(Subv): When are the other running/ready threads terminated? -- cgit v1.2.3