diff options
| author | bunnei <bunneidev@gmail.com> | 2022-06-22 14:46:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-22 14:46:33 -0700 |
| commit | 9da4e62573cdaa8a48dd18068642b494cfed9a04 (patch) | |
| tree | c179c5fa993f3e840d6e0051ae28ad04520e2723 /src/core/hle/kernel/k_thread.cpp | |
| parent | ab0e71d7cb5f75c6a7b5269bc36c46820a825b12 (diff) | |
| parent | 24d7aaf43c6b243f7123401545527ed7a25a3f26 (diff) | |
Merge pull request #8483 from liamwhite/fire-emblem-three-semaphores
kernel: wait for threads to stop on pause
Diffstat (limited to 'src/core/hle/kernel/k_thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/k_thread.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 268789150..c0a091bb6 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp @@ -748,6 +748,19 @@ void KThread::Continue() { KScheduler::OnThreadStateChanged(kernel, this, old_state); } +void KThread::WaitUntilSuspended() { + // Make sure we have a suspend requested. + ASSERT(IsSuspendRequested()); + + // Loop until the thread is not executing on any core. + for (std::size_t i = 0; i < static_cast<std::size_t>(Core::Hardware::NUM_CPU_CORES); ++i) { + KThread* core_thread{}; + do { + core_thread = kernel.Scheduler(i).GetCurrentThread(); + } while (core_thread == this); + } +} + ResultCode KThread::SetActivity(Svc::ThreadActivity activity) { // Lock ourselves. KScopedLightLock lk(activity_pause_lock); |
