read-decrement-write locked
This commit is contained in:
parent
d2815e9420
commit
6be0c1ae89
1 changed files with 25 additions and 7 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue