diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-03-05 03:46:22 +0100 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-06-27 17:35:26 +0200 |
commit | a6bce296ad3fa8e7da66df3d32cd148448ac0abb (patch) | |
tree | 8f34d1546bb17d88b04a9aabdf62b01bbcc10eb5 /src/core/hle | |
parent | SVC: Correct svcWaitForAddress and svcSignalToAddress. (diff) | |
download | yuzu-a6bce296ad3fa8e7da66df3d32cd148448ac0abb.tar yuzu-a6bce296ad3fa8e7da66df3d32cd148448ac0abb.tar.gz yuzu-a6bce296ad3fa8e7da66df3d32cd148448ac0abb.tar.bz2 yuzu-a6bce296ad3fa8e7da66df3d32cd148448ac0abb.tar.lz yuzu-a6bce296ad3fa8e7da66df3d32cd148448ac0abb.tar.xz yuzu-a6bce296ad3fa8e7da66df3d32cd148448ac0abb.tar.zst yuzu-a6bce296ad3fa8e7da66df3d32cd148448ac0abb.zip |
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/kernel/mutex.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 18325db57..ebe3f6050 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -9,6 +9,7 @@ #include "common/assert.h" #include "common/logging/log.h" #include "core/core.h" +#include "core/arm/exclusive_monitor.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/kernel.h" @@ -133,8 +134,12 @@ std::pair<ResultCode, std::shared_ptr<Thread>> Mutex::Unlock(std::shared_ptr<Thr } auto [new_owner, num_waiters] = GetHighestPriorityMutexWaitingThread(owner, address); + auto& monitor = system.Monitor(); + const std::size_t current_core = system.CurrentCoreIndex(); if (new_owner == nullptr) { - system.Memory().Write32(address, 0); + do { + monitor.SetExclusive(current_core, address); + } while (!monitor.ExclusiveWrite32(current_core, address, 0)); return {RESULT_SUCCESS, nullptr}; } // Transfer the ownership of the mutex from the previous owner to the new one. @@ -145,9 +150,12 @@ std::pair<ResultCode, std::shared_ptr<Thread>> Mutex::Unlock(std::shared_ptr<Thr mutex_value |= Mutex::MutexHasWaitersFlag; } new_owner->SetSynchronizationResults(nullptr, RESULT_SUCCESS); - new_owner->ResumeFromWait(); new_owner->SetLockOwner(nullptr); - system.Memory().Write32(address, mutex_value); + new_owner->ResumeFromWait(); + + do { + monitor.SetExclusive(current_core, address); + } while (!monitor.ExclusiveWrite32(current_core, address, mutex_value)); return {RESULT_SUCCESS, new_owner}; } |