read-decrement-write locked

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

View file

@ -35,18 +35,36 @@ namespace Ryujinx.HLE.OsHle.Kernel
ulong Timeout, ulong Timeout,
bool ShouldDecrement) bool ShouldDecrement)
{ {
Memory.SetExclusive(ThreadState, Address);
int CurrentValue = Memory.ReadInt32(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 Memory.SetExclusive(ThreadState, Address);
{
return MakeError(ErrorModule.Kernel, KernelErr.InvalidState); CurrentValue = Memory.ReadInt32(Address);
} }
if (Timeout == 0) if (Timeout == 0)