read-decrement-write locked

This commit is contained in:
Ac_K 2018-07-19 05:57:54 +02:00
parent d2815e9420
commit 6be0c1ae89

View file

@ -35,18 +35,36 @@ namespace Ryujinx.HLE.OsHle.Kernel
ulong Timeout,
bool ShouldDecrement)
{
Memory.SetExclusive(ThreadState, Address);
int CurrentValue = Memory.ReadInt32(Address);
if (CurrentValue < Value)
while (true)
{
if (ShouldDecrement)
if (Memory.TestExclusive(ThreadState, Address))
{
Memory.WriteInt32(Address, CurrentValue - 1);
if (CurrentValue < Value)
{
if (ShouldDecrement)
{
Memory.WriteInt32(Address, CurrentValue - 1);
}
Memory.ClearExclusiveForStore(ThreadState);
}
else
{
Memory.ClearExclusiveForStore(ThreadState);
return MakeError(ErrorModule.Kernel, KernelErr.InvalidState);
}
break;
}
}
else
{
return MakeError(ErrorModule.Kernel, KernelErr.InvalidState);
Memory.SetExclusive(ThreadState, Address);
CurrentValue = Memory.ReadInt32(Address);
}
if (Timeout == 0)