1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

lv2: Fix lwmutex locking

This commit is contained in:
eladash 2018-10-17 08:16:30 +03:00 committed by Ivan
parent 777f36e604
commit 3faaf9e7fb
2 changed files with 7 additions and 21 deletions

View File

@ -266,7 +266,7 @@ error_code _sys_lwcond_queue_wait(ppu_thread& ppu, u32 lwcond_id, u32 lwmutex_id
return cpu;
}
mutex->signaled++;
mutex->signaled = 1;
return nullptr;
});

View File

@ -75,22 +75,16 @@ error_code _sys_lwmutex_lock(ppu_thread& ppu, u32 lwmutex_id, u64 timeout)
const auto mutex = idm::get<lv2_obj, lv2_lwmutex>(lwmutex_id, [&](lv2_lwmutex& mutex)
{
if (u32 value = mutex.signaled)
if (mutex.signaled.try_dec())
{
if (mutex.signaled.compare_and_swap_test(value, value - 1))
{
return true;
}
return true;
}
std::lock_guard lock(mutex.mutex);
if (u32 value = mutex.signaled)
if (mutex.signaled.try_dec())
{
if (mutex.signaled.compare_and_swap_test(value, value - 1))
{
return true;
}
return true;
}
mutex.sq.emplace_back(&ppu);
@ -152,15 +146,7 @@ error_code _sys_lwmutex_trylock(u32 lwmutex_id)
const auto mutex = idm::check<lv2_obj, lv2_lwmutex>(lwmutex_id, [&](lv2_lwmutex& mutex)
{
if (u32 value = mutex.signaled)
{
if (mutex.signaled.compare_and_swap_test(value, value - 1))
{
return true;
}
}
return false;
return mutex.signaled.try_dec();
});
if (!mutex)
@ -189,7 +175,7 @@ error_code _sys_lwmutex_unlock(ppu_thread& ppu, u32 lwmutex_id)
return cpu;
}
mutex.signaled++;
mutex.signaled = 1;
return nullptr;
});