From 4546d1b9be1052bbf82858d97795b33355bf64da Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 13 May 2018 00:22:42 -0300 Subject: Initial work to support changing thread core on the scheduler, also some cond var priority fixes --- Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs') diff --git a/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs b/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs index 57608cda..0ca2a5f9 100644 --- a/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs +++ b/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs @@ -260,17 +260,23 @@ namespace Ryujinx.Core.OsHle.Kernel WaitThread.MutexAddress = MutexAddress; WaitThread.CondVarAddress = CondVarAddress; - lock (CondVarLock) + lock (Process.ThreadArbiterListLock) { - KThread CurrThread = Process.ThreadArbiterList; + KThread CurrThread = Process.ThreadArbiterListHead; - if (CurrThread != null) + if (CurrThread == null || CurrThread.ActualPriority > WaitThread.ActualPriority) + { + WaitThread.NextCondVarThread = Process.ThreadArbiterListHead; + + Process.ThreadArbiterListHead = WaitThread; + } + else { bool DoInsert = CurrThread != WaitThread; while (CurrThread.NextCondVarThread != null) { - if (CurrThread.NextCondVarThread.ActualPriority < WaitThread.ActualPriority) + if (CurrThread.NextCondVarThread.ActualPriority > WaitThread.ActualPriority) { break; } @@ -293,10 +299,6 @@ namespace Ryujinx.Core.OsHle.Kernel CurrThread.NextCondVarThread = WaitThread; } } - else - { - Process.ThreadArbiterList = WaitThread; - } } Ns.Log.PrintDebug(LogClass.KernelSvc, "Entering wait state..."); @@ -315,10 +317,10 @@ namespace Ryujinx.Core.OsHle.Kernel private void CondVarSignal(long CondVarAddress, int Count) { - lock (CondVarLock) + lock (Process.ThreadArbiterListLock) { KThread PrevThread = null; - KThread CurrThread = Process.ThreadArbiterList; + KThread CurrThread = Process.ThreadArbiterListHead; while (CurrThread != null && (Count == -1 || Count > 0)) { @@ -330,7 +332,7 @@ namespace Ryujinx.Core.OsHle.Kernel } else { - Process.ThreadArbiterList = CurrThread.NextCondVarThread; + Process.ThreadArbiterListHead = CurrThread.NextCondVarThread; } CurrThread.NextCondVarThread = null; @@ -401,7 +403,7 @@ namespace Ryujinx.Core.OsHle.Kernel return; } - if (CurrThread.NextMutexThread.ActualPriority < WaitThread.ActualPriority) + if (CurrThread.NextMutexThread.ActualPriority > WaitThread.ActualPriority) { break; } -- cgit v1.2.3