From fdfa9424c8fb05821a39965d88b3dbcc402fb57b Mon Sep 17 00:00:00 2001 From: gdkchan Date: Mon, 14 May 2018 03:09:08 -0300 Subject: [PATCH] Fix typo and update priority/avoid duplicates on UpdateMutexOwner --- Ryujinx.Core/OsHle/Kernel/SvcThread.cs | 2 +- Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs | 44 +++++++++++----------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Ryujinx.Core/OsHle/Kernel/SvcThread.cs b/Ryujinx.Core/OsHle/Kernel/SvcThread.cs index 597e42a6d..f0f3d95b8 100644 --- a/Ryujinx.Core/OsHle/Kernel/SvcThread.cs +++ b/Ryujinx.Core/OsHle/Kernel/SvcThread.cs @@ -155,7 +155,7 @@ namespace Ryujinx.Core.OsHle.Kernel if (IdealCore == -2) { - //TODO: Get this valcdue from the NPDM file. + //TODO: Get this value from the NPDM file. IdealCore = 0; CoreMask = 1 << IdealCore; diff --git a/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs b/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs index 280065ec4..f9e035ad0 100644 --- a/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs +++ b/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs @@ -330,6 +330,28 @@ namespace Ryujinx.Core.OsHle.Kernel } } + private void UpdateMutexOwner(KThread CurrThread, KThread NewOwner, long MutexAddress) + { + //Go through all threads waiting for the mutex, + //and update the MutexOwner field to point to the new owner. + lock (Process.ThreadSyncLock) + { + for (int Index = 0; Index < CurrThread.MutexWaiters.Count; Index++) + { + KThread Thread = CurrThread.MutexWaiters[Index]; + + if (Thread.MutexAddress == MutexAddress) + { + CurrThread.MutexWaiters.RemoveAt(Index--); + + Thread.MutexOwner = NewOwner; + + InsertWaitingMutexThread(NewOwner, Thread); + } + } + } + } + private void InsertWaitingMutexThread(int OwnerThreadHandle, KThread WaitThread) { KThread OwnerThread = Process.HandleTable.GetData(OwnerThreadHandle); @@ -359,28 +381,6 @@ namespace Ryujinx.Core.OsHle.Kernel } } - private void UpdateMutexOwner(KThread CurrThread, KThread NewOwner, long MutexAddress) - { - //Go through all threads waiting for the mutex, - //and update the MutexOwner field to point to the new owner. - lock (Process.ThreadSyncLock) - { - for (int Index = 0; Index < CurrThread.MutexWaiters.Count; Index++) - { - KThread Thread = CurrThread.MutexWaiters[Index]; - - if (Thread.MutexAddress == MutexAddress) - { - CurrThread.MutexWaiters.RemoveAt(Index--); - - Thread.MutexOwner = NewOwner; - - NewOwner.MutexWaiters.Add(Thread); - } - } - } - } - private KThread GetHighestPriority(List Threads, long MutexAddress) { return GetHighestPriority(Threads, x => x.MutexAddress == MutexAddress);