mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-01-05 08:10:10 +01:00
sys_mutex/lwmutex: Regression fixes after #12378
This commit is contained in:
parent
c4cc0154be
commit
f0002501f7
|
|
@ -318,6 +318,9 @@ error_code sys_cond_wait(ppu_thread& ppu, u32 cond_id, u64 timeout)
|
|||
return static_cast<u32>(syscall_state >> 32);
|
||||
}
|
||||
|
||||
// Register waiter
|
||||
lv2_obj::emplace(cond.sq, &ppu);
|
||||
|
||||
// Unlock the mutex
|
||||
const u32 count = cond.mutex->lock_count.exchange(0);
|
||||
|
||||
|
|
@ -325,6 +328,7 @@ error_code sys_cond_wait(ppu_thread& ppu, u32 cond_id, u64 timeout)
|
|||
{
|
||||
if (cpu->state & cpu_flag::again)
|
||||
{
|
||||
ensure(cond.unqueue(cond.sq, &ppu));
|
||||
ppu.state += cpu_flag::again;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -332,9 +336,6 @@ error_code sys_cond_wait(ppu_thread& ppu, u32 cond_id, u64 timeout)
|
|||
cond.mutex->append(cpu);
|
||||
}
|
||||
|
||||
// Register waiter
|
||||
lv2_obj::emplace(cond.sq, &ppu);
|
||||
|
||||
// Sleep current thread and schedule mutex waiter
|
||||
cond.sleep(ppu, timeout);
|
||||
|
||||
|
|
|
|||
|
|
@ -123,6 +123,11 @@ struct lv2_lwmutex final : lv2_obj
|
|||
lwcond_waiters.notify_all();
|
||||
}
|
||||
|
||||
if (signal)
|
||||
{
|
||||
cpu->next_cpu = nullptr;
|
||||
}
|
||||
|
||||
return signal;
|
||||
}
|
||||
|
||||
|
|
@ -158,8 +163,9 @@ struct lv2_lwmutex final : lv2_obj
|
|||
res = nullptr;
|
||||
}
|
||||
|
||||
if (auto sq = data.sq)
|
||||
if (auto sq = static_cast<T*>(data.sq))
|
||||
{
|
||||
restore_next = sq->next_cpu;
|
||||
res = schedule<T>(data.sq, protocol);
|
||||
|
||||
if (sq == data.sq)
|
||||
|
|
@ -167,7 +173,6 @@ struct lv2_lwmutex final : lv2_obj
|
|||
return false;
|
||||
}
|
||||
|
||||
restore_next = res->next_cpu;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ struct lv2_mutex final : lv2_obj
|
|||
template <typename T>
|
||||
bool try_own(T& cpu)
|
||||
{
|
||||
return control.atomic_op([&](control_data_t& data)
|
||||
if (control.atomic_op([&](control_data_t& data)
|
||||
{
|
||||
if (data.owner)
|
||||
{
|
||||
|
|
@ -114,7 +114,13 @@ struct lv2_mutex final : lv2_obj
|
|||
data.owner = cpu.id;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}))
|
||||
{
|
||||
cpu.next_cpu = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -161,8 +167,9 @@ struct lv2_mutex final : lv2_obj
|
|||
res = nullptr;
|
||||
}
|
||||
|
||||
if (auto sq = data.sq)
|
||||
if (auto sq = static_cast<T*>(data.sq))
|
||||
{
|
||||
restore_next = sq->next_cpu;
|
||||
res = schedule<T>(data.sq, protocol);
|
||||
|
||||
if (sq == data.sq)
|
||||
|
|
@ -171,7 +178,6 @@ struct lv2_mutex final : lv2_obj
|
|||
return false;
|
||||
}
|
||||
|
||||
restore_next = res->next_cpu;
|
||||
data.owner = res->id;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue