mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-30 23:15:47 +00:00
Fix small bug that kept a thread as a condvar thread after being signalled.
This commit is contained in:
parent
acbdfdae64
commit
9c7319a4d4
|
@ -62,7 +62,8 @@ static void ThreadWakeupCallback(u64 thread_handle, [[maybe_unused]] int cycles_
|
||||||
|
|
||||||
if (thread->GetMutexWaitAddress() != 0 || thread->GetCondVarWaitAddress() != 0 ||
|
if (thread->GetMutexWaitAddress() != 0 || thread->GetCondVarWaitAddress() != 0 ||
|
||||||
thread->GetWaitHandle() != 0) {
|
thread->GetWaitHandle() != 0) {
|
||||||
ASSERT(thread->GetStatus() == ThreadStatus::WaitMutex || thread->GetStatus() == ThreadStatus::WaitCondVar);
|
ASSERT(thread->GetStatus() == ThreadStatus::WaitMutex ||
|
||||||
|
thread->GetStatus() == ThreadStatus::WaitCondVar);
|
||||||
thread->SetMutexWaitAddress(0);
|
thread->SetMutexWaitAddress(0);
|
||||||
thread->SetCondVarWaitAddress(0);
|
thread->SetCondVarWaitAddress(0);
|
||||||
thread->SetWaitHandle(0);
|
thread->SetWaitHandle(0);
|
||||||
|
|
|
@ -1405,6 +1405,9 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target
|
||||||
|
|
||||||
ASSERT(thread->GetCondVarWaitAddress() == condition_variable_addr);
|
ASSERT(thread->GetCondVarWaitAddress() == condition_variable_addr);
|
||||||
|
|
||||||
|
// liberate Cond Var Thread.
|
||||||
|
thread->SetCondVarWaitAddress(0);
|
||||||
|
|
||||||
std::size_t current_core = Core::System::GetInstance().CurrentCoreIndex();
|
std::size_t current_core = Core::System::GetInstance().CurrentCoreIndex();
|
||||||
|
|
||||||
auto& monitor = Core::System::GetInstance().Monitor();
|
auto& monitor = Core::System::GetInstance().Monitor();
|
||||||
|
@ -1423,10 +1426,9 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target
|
||||||
}
|
}
|
||||||
} while (!monitor.ExclusiveWrite32(current_core, thread->GetMutexWaitAddress(),
|
} while (!monitor.ExclusiveWrite32(current_core, thread->GetMutexWaitAddress(),
|
||||||
thread->GetWaitHandle()));
|
thread->GetWaitHandle()));
|
||||||
|
|
||||||
if (mutex_val == 0) {
|
if (mutex_val == 0) {
|
||||||
// We were able to acquire the mutex, resume this thread.
|
// We were able to acquire the mutex, resume this thread.
|
||||||
ASSERT(thread->GetStatus() == ThreadStatus::WaitMutex);
|
ASSERT(thread->GetStatus() == ThreadStatus::WaitCondVar);
|
||||||
thread->ResumeFromWait();
|
thread->ResumeFromWait();
|
||||||
|
|
||||||
auto* const lock_owner = thread->GetLockOwner();
|
auto* const lock_owner = thread->GetLockOwner();
|
||||||
|
@ -1436,8 +1438,8 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target
|
||||||
|
|
||||||
thread->SetLockOwner(nullptr);
|
thread->SetLockOwner(nullptr);
|
||||||
thread->SetMutexWaitAddress(0);
|
thread->SetMutexWaitAddress(0);
|
||||||
thread->SetCondVarWaitAddress(0);
|
|
||||||
thread->SetWaitHandle(0);
|
thread->SetWaitHandle(0);
|
||||||
|
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
||||||
} else {
|
} else {
|
||||||
// Atomically signal that the mutex now has a waiting thread.
|
// Atomically signal that the mutex now has a waiting thread.
|
||||||
do {
|
do {
|
||||||
|
@ -1458,10 +1460,9 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target
|
||||||
ASSERT(owner);
|
ASSERT(owner);
|
||||||
ASSERT(thread->GetStatus() == ThreadStatus::WaitCondVar);
|
ASSERT(thread->GetStatus() == ThreadStatus::WaitCondVar);
|
||||||
thread->InvalidateWakeupCallback();
|
thread->InvalidateWakeupCallback();
|
||||||
|
thread->SetStatus(ThreadStatus::WaitMutex);
|
||||||
|
|
||||||
owner->AddMutexWaiter(thread);
|
owner->AddMutexWaiter(thread);
|
||||||
|
|
||||||
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue