diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/k_thread.cpp | 15 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.h | 4 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 70480b725..908811e2c 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | #include <algorithm> | 4 | #include <algorithm> |
| 5 | #include <atomic> | 5 | #include <atomic> |
| 6 | #include <cinttypes> | 6 | #include <cinttypes> |
| 7 | #include <condition_variable> | ||
| 8 | #include <mutex> | ||
| 7 | #include <optional> | 9 | #include <optional> |
| 8 | #include <vector> | 10 | #include <vector> |
| 9 | 11 | ||
| @@ -1313,7 +1315,8 @@ void KThread::RequestDummyThreadWait() { | |||
| 1313 | ASSERT(this->IsDummyThread()); | 1315 | ASSERT(this->IsDummyThread()); |
| 1314 | 1316 | ||
| 1315 | // We will block when the scheduler lock is released. | 1317 | // We will block when the scheduler lock is released. |
| 1316 | m_dummy_thread_runnable.store(false); | 1318 | std::scoped_lock lock{m_dummy_thread_mutex}; |
| 1319 | m_dummy_thread_runnable = false; | ||
| 1317 | } | 1320 | } |
| 1318 | 1321 | ||
| 1319 | void KThread::DummyThreadBeginWait() { | 1322 | void KThread::DummyThreadBeginWait() { |
| @@ -1323,7 +1326,8 @@ void KThread::DummyThreadBeginWait() { | |||
| 1323 | } | 1326 | } |
| 1324 | 1327 | ||
| 1325 | // Block until runnable is no longer false. | 1328 | // Block until runnable is no longer false. |
| 1326 | m_dummy_thread_runnable.wait(false); | 1329 | std::unique_lock lock{m_dummy_thread_mutex}; |
| 1330 | m_dummy_thread_cv.wait(lock, [this] { return m_dummy_thread_runnable; }); | ||
| 1327 | } | 1331 | } |
| 1328 | 1332 | ||
| 1329 | void KThread::DummyThreadEndWait() { | 1333 | void KThread::DummyThreadEndWait() { |
| @@ -1331,8 +1335,11 @@ void KThread::DummyThreadEndWait() { | |||
| 1331 | ASSERT(this->IsDummyThread()); | 1335 | ASSERT(this->IsDummyThread()); |
| 1332 | 1336 | ||
| 1333 | // Wake up the waiting thread. | 1337 | // Wake up the waiting thread. |
| 1334 | m_dummy_thread_runnable.store(true); | 1338 | { |
| 1335 | m_dummy_thread_runnable.notify_one(); | 1339 | std::scoped_lock lock{m_dummy_thread_mutex}; |
| 1340 | m_dummy_thread_runnable = true; | ||
| 1341 | } | ||
| 1342 | m_dummy_thread_cv.notify_one(); | ||
| 1336 | } | 1343 | } |
| 1337 | 1344 | ||
| 1338 | void KThread::BeginWait(KThreadQueue* queue) { | 1345 | void KThread::BeginWait(KThreadQueue* queue) { |
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index f9814ac8f..37fe5db77 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h | |||
| @@ -892,7 +892,9 @@ private: | |||
| 892 | std::shared_ptr<Common::Fiber> m_host_context{}; | 892 | std::shared_ptr<Common::Fiber> m_host_context{}; |
| 893 | ThreadType m_thread_type{}; | 893 | ThreadType m_thread_type{}; |
| 894 | StepState m_step_state{}; | 894 | StepState m_step_state{}; |
| 895 | std::atomic<bool> m_dummy_thread_runnable{true}; | 895 | bool m_dummy_thread_runnable{true}; |
| 896 | std::mutex m_dummy_thread_mutex{}; | ||
| 897 | std::condition_variable m_dummy_thread_cv{}; | ||
| 896 | 898 | ||
| 897 | // For debugging | 899 | // For debugging |
| 898 | std::vector<KSynchronizationObject*> m_wait_objects_for_debugging{}; | 900 | std::vector<KSynchronizationObject*> m_wait_objects_for_debugging{}; |