void sys_spinlock_lock(vm::ptr<atomic_be_t<u32>> lock) { sysPrxForUser.Log("sys_spinlock_lock(lock=*0x%x)", lock); // prx: exchange with 0xabadcafe, repeat until exchanged with 0 while (lock->exchange(be_t<u32>::make(0xabadcafe)).data()) { g_sys_spinlock_wm.wait_op(lock.addr(), [lock](){ return lock->read_relaxed().data() == 0; }); if (Emu.IsStopped()) { sysPrxForUser.Warning("sys_spinlock_lock(lock=*0x%x) aborted", lock); break; } } }
void sys_spinlock_lock(vm::ptr<atomic_t<u32>> lock) { sys_spinlock.Log("sys_spinlock_lock(lock_addr=0x%x)", lock.addr()); // prx: exchange with 0xabadcafe, repeat until exchanged with 0 while (lock->exchange(be_t<u32>::make(0xabadcafe)).data()) { while (lock->read_relaxed().data()) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack if (Emu.IsStopped()) { break; } } if (Emu.IsStopped()) { sys_spinlock.Warning("sys_spinlock_lock(0x%x) aborted", lock.addr()); break; } } }