mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
Improve vm::reservation_update
Only respect unique lock.
This commit is contained in:
parent
2f329cf7b5
commit
1885e4345c
4 changed files with 19 additions and 18 deletions
|
|
@ -80,15 +80,25 @@ namespace vm
|
|||
// Memory pages
|
||||
std::array<memory_page, 0x100000000 / 4096> g_pages{};
|
||||
|
||||
void reservation_update(u32 addr, u32 size, bool lsb)
|
||||
std::pair<bool, u64> try_reservation_update(u32 addr)
|
||||
{
|
||||
// Update reservation info with new timestamp
|
||||
auto& res = reservation_acquire(addr, 1);
|
||||
const u64 rtime = res;
|
||||
|
||||
return {!(rtime & vm::rsrv_unique_lock) && res.compare_and_swap_test(rtime, rtime + 128), rtime};
|
||||
}
|
||||
|
||||
void reservation_update(u32 addr)
|
||||
{
|
||||
u64 old = UINT64_MAX;
|
||||
const auto cpu = get_current_cpu_thread();
|
||||
|
||||
while (true)
|
||||
{
|
||||
const auto [ok, rtime] = try_reservation_update(addr, size, lsb);
|
||||
if (ok || old / 128 < rtime / 128)
|
||||
const auto [ok, rtime] = try_reservation_update(addr);
|
||||
|
||||
if (ok || (old & -128) < (rtime & -128))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue