liblv2 HLE: Fix sys_lwcond_signal mode 3

This commit is contained in:
Eladash 2020-04-03 18:11:05 +03:00 committed by Ivan
parent 13820d6802
commit 55baaea8e7
2 changed files with 22 additions and 6 deletions

View File

@ -100,7 +100,11 @@ error_code sys_lwcond_signal(ppu_thread& ppu, vm::ptr<sys_lwcond_t> lwcond)
}
// if locking succeeded
lwmutex->all_info++;
lwmutex->lock_var.atomic_op([](typename sys_lwmutex_t::sync_var_t& var)
{
var.waiter++;
var.owner = lwmutex_reserved;
});
// call the syscall
if (error_code res = _sys_lwcond_signal(ppu, lwcond->lwcond_queue, lwmutex->sleep_queue, -1, 3))
@ -110,7 +114,11 @@ error_code sys_lwcond_signal(ppu_thread& ppu, vm::ptr<sys_lwcond_t> lwcond)
return 0;
}
lwmutex->all_info--;
lwmutex->lock_var.atomic_op([&](typename sys_lwmutex_t::sync_var_t& var)
{
var.waiter--;
var.owner = ppu.id;
});
// unlock the lightweight mutex
sys_lwmutex_unlock(ppu, lwmutex);
@ -245,7 +253,11 @@ error_code sys_lwcond_signal_to(ppu_thread& ppu, vm::ptr<sys_lwcond_t> lwcond, u
}
// if locking succeeded
lwmutex->all_info++;
lwmutex->lock_var.atomic_op([](typename sys_lwmutex_t::sync_var_t& var)
{
var.waiter++;
var.owner = lwmutex_reserved;
});
// call the syscall
if (error_code res = _sys_lwcond_signal(ppu, lwcond->lwcond_queue, lwmutex->sleep_queue, ppu_thread_id, 3))
@ -255,7 +267,11 @@ error_code sys_lwcond_signal_to(ppu_thread& ppu, vm::ptr<sys_lwcond_t> lwcond, u
return 0;
}
lwmutex->all_info--;
lwmutex->lock_var.atomic_op([&](typename sys_lwmutex_t::sync_var_t& var)
{
var.waiter--;
var.owner = ppu.id;
});
// unlock the lightweight mutex
sys_lwmutex_unlock(ppu, lwmutex);

View File

@ -178,7 +178,7 @@ error_code sys_lwmutex_lock(ppu_thread& ppu, vm::ptr<sys_lwmutex_t> lwmutex, u64
// locking succeeded
auto old = lwmutex->vars.owner.exchange(tid);
if (old != lwmutex_reserved && old >> 24 != 1)
if (old != lwmutex_reserved)
{
fmt::throw_exception("Locking failed (lwmutex=*0x%x, owner=0x%x)" HERE, lwmutex, old);
}
@ -308,7 +308,7 @@ error_code sys_lwmutex_trylock(ppu_thread& ppu, vm::ptr<sys_lwmutex_t> lwmutex)
// locking succeeded
auto old = lwmutex->vars.owner.exchange(tid);
if (old != lwmutex_reserved && old >> 24 != 1)
if (old != lwmutex_reserved)
{
fmt::throw_exception("Locking failed (lwmutex=*0x%x, owner=0x%x)" HERE, lwmutex, old);
}