diff options
author | bunnei <bunneidev@gmail.com> | 2018-02-04 18:30:51 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-02-04 18:30:51 +0100 |
commit | 0b6b147939c3abd1f98ecf639fb1ee51c5a445a1 (patch) | |
tree | f1211ba8e29d7e3eae11fc64453e3e71ee4711c1 /src/core/hle/kernel/svc.cpp | |
parent | svc: SharedMemory size should be 64-bits and cleanup. (diff) | |
download | yuzu-0b6b147939c3abd1f98ecf639fb1ee51c5a445a1.tar yuzu-0b6b147939c3abd1f98ecf639fb1ee51c5a445a1.tar.gz yuzu-0b6b147939c3abd1f98ecf639fb1ee51c5a445a1.tar.bz2 yuzu-0b6b147939c3abd1f98ecf639fb1ee51c5a445a1.tar.lz yuzu-0b6b147939c3abd1f98ecf639fb1ee51c5a445a1.tar.xz yuzu-0b6b147939c3abd1f98ecf639fb1ee51c5a445a1.tar.zst yuzu-0b6b147939c3abd1f98ecf639fb1ee51c5a445a1.zip |
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 4e395ed31..0705b264d 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -612,20 +612,29 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var mutex->name = Common::StringFromFormat("mutex-%llx", mutex_addr); } - ASSERT(mutex->GetOwnerHandle() == thread_handle); - SharedPtr<ConditionVariable> condition_variable = g_object_address_table.Get<ConditionVariable>(condition_variable_addr); if (!condition_variable) { // Create a new condition_variable for the specified address if one does not already exist - condition_variable = - ConditionVariable::Create(condition_variable_addr, mutex_addr).Unwrap(); + condition_variable = ConditionVariable::Create(condition_variable_addr).Unwrap(); condition_variable->name = Common::StringFromFormat("condition-variable-%llx", condition_variable_addr); } - ASSERT(condition_variable->GetAvailableCount() == 0); - ASSERT(condition_variable->mutex_addr == mutex_addr); + if (condition_variable->mutex_addr) { + // Previously created the ConditionVariable using WaitProcessWideKeyAtomic, verify + // everything is correct + ASSERT(condition_variable->mutex_addr == mutex_addr); + } else { + // Previously created the ConditionVariable using SignalProcessWideKey, set the mutex + // associated with it + condition_variable->mutex_addr = mutex_addr; + } + + if (mutex->GetOwnerHandle()) { + // Release the mutex if the current thread is holding it + mutex->Release(thread.get()); + } auto wakeup_callback = [mutex, nano_seconds](ThreadWakeupReason reason, SharedPtr<Thread> thread, @@ -667,8 +676,6 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var CASCADE_CODE( WaitSynchronization1(condition_variable, thread.get(), nano_seconds, wakeup_callback)); - mutex->Release(thread.get()); - return RESULT_SUCCESS; } |