mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-08-02 08:37:09 +02:00
Initial work to support changing thread core on the scheduler, also some cond var priority fixes
This commit is contained in:
parent
87ef9366f2
commit
e65ea8506b
9 changed files with 442 additions and 199 deletions
|
@ -22,8 +22,6 @@ namespace Ryujinx.Core.OsHle.Kernel
|
|||
|
||||
private ConcurrentDictionary<KThread, AutoResetEvent> SyncWaits;
|
||||
|
||||
private object CondVarLock;
|
||||
|
||||
private HashSet<(HSharedMem, long)> MappedSharedMems;
|
||||
|
||||
private ulong CurrentHeapSize;
|
||||
|
@ -80,8 +78,6 @@ namespace Ryujinx.Core.OsHle.Kernel
|
|||
|
||||
SyncWaits = new ConcurrentDictionary<KThread, AutoResetEvent>();
|
||||
|
||||
CondVarLock = new object();
|
||||
|
||||
MappedSharedMems = new HashSet<(HSharedMem, long)>();
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace Ryujinx.Core.OsHle.Kernel
|
|||
|
||||
Handles[HandlesCount] = WaitEvent;
|
||||
|
||||
Process.Scheduler.Suspend(CurrThread.ProcessorId);
|
||||
Process.Scheduler.Suspend(CurrThread);
|
||||
|
||||
int HandleIndex;
|
||||
|
||||
|
@ -237,7 +237,7 @@ namespace Ryujinx.Core.OsHle.Kernel
|
|||
|
||||
if (Session != null)
|
||||
{
|
||||
Process.Scheduler.Suspend(CurrThread.ProcessorId);
|
||||
Process.Scheduler.Suspend(CurrThread);
|
||||
|
||||
IpcMessage Cmd = new IpcMessage(CmdData, CmdPtr);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace Ryujinx.Core.OsHle.Kernel
|
|||
}
|
||||
else
|
||||
{
|
||||
Process.Scheduler.Suspend(CurrThread.ProcessorId);
|
||||
Process.Scheduler.Suspend(CurrThread);
|
||||
|
||||
Thread.Sleep(NsTimeConverter.GetTimeMs(Ns));
|
||||
|
||||
|
@ -132,7 +132,7 @@ namespace Ryujinx.Core.OsHle.Kernel
|
|||
|
||||
private void SvcGetCurrentProcessorNumber(AThreadState ThreadState)
|
||||
{
|
||||
ThreadState.X0 = (ulong)Process.GetThread(ThreadState.Tpidr).ProcessorId;
|
||||
ThreadState.X0 = (ulong)Process.GetThread(ThreadState.Tpidr).ActualCore;
|
||||
}
|
||||
|
||||
private void SvcGetThreadId(AThreadState ThreadState)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue