SPU: Use optimized PPU signaling to SPU on reservation pause

This commit is contained in:
Eladash 2020-05-09 08:42:59 +03:00 committed by Ani
parent 525453794f
commit b38580bf32
2 changed files with 68 additions and 41 deletions

View file

@ -129,9 +129,30 @@ namespace vm
{
if (g_tls_locked && *g_tls_locked == &cpu) [[unlikely]]
{
if (cpu.state & cpu_flag::wait)
{
while (true)
{
g_mutex.lock_unlock();
cpu.state -= cpu_flag::wait + cpu_flag::memory;
if (g_mutex.is_lockable()) [[likely]]
{
return;
}
cpu.state += cpu_flag::wait;
}
}
return;
}
if (cpu.state & cpu_flag::memory)
{
cpu.state -= cpu_flag::memory;
}
if (g_mutex.is_lockable()) [[likely]]
{
// Optimistic path (hope that mutex is not exclusively locked)
@ -355,7 +376,8 @@ namespace vm
for (auto lock = g_locks.cbegin(), end = lock + g_cfg.core.ppu_threads; lock != end; lock++)
{
while (*lock)
cpu_thread* ptr;
while ((ptr = *lock) && !(ptr->state & cpu_flag::wait))
{
_mm_pause();
}