1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-10-01 12:30:00 +02:00

Only use higher priority on yield, change reschedule to be per-thread instead of using SchedulerThread to store the reschedule flag

This commit is contained in:
gdkchan 2018-05-15 23:49:57 -03:00
parent 73a3233d57
commit 9b9ead94cd
4 changed files with 13 additions and 17 deletions

View file

@ -13,6 +13,8 @@ namespace Ryujinx.Core.OsHle.Handles
private KThread[] CoreThreads;
private bool[] CoreReschedule;
private object SchedLock;
private Logger Log;
@ -27,6 +29,8 @@ namespace Ryujinx.Core.OsHle.Handles
CoreThreads = new KThread[4];
CoreReschedule = new bool[4];
SchedLock = new object();
}
@ -147,10 +151,10 @@ namespace Ryujinx.Core.OsHle.Handles
{
PrintDbgThreadInfo(Thread, "suspended.");
AllThreads[Thread].NeedsReschedule = false;
int ActualCore = Thread.ActualCore;
CoreReschedule[ActualCore] = false;
SchedulerThread SchedThread = WaitingToRun.Pop(ActualCore);
if (SchedThread != null)
@ -174,26 +178,21 @@ namespace Ryujinx.Core.OsHle.Handles
{
lock (SchedLock)
{
KThread Thread = CoreThreads[Core];
if (Thread != null && AllThreads.TryGetValue(Thread, out SchedulerThread SchedThread))
{
SchedThread.NeedsReschedule = true;
}
CoreReschedule[Core] = true;
}
}
public void Reschedule(KThread Thread)
{
SchedulerThread SchedThread = AllThreads[Thread];
bool NeedsReschedule;
lock (SchedLock)
{
NeedsReschedule = SchedThread.NeedsReschedule;
int ActualCore = Thread.ActualCore;
SchedThread.NeedsReschedule = false;
NeedsReschedule = CoreReschedule[ActualCore];
CoreReschedule[ActualCore] = false;
}
if (NeedsReschedule)
@ -220,7 +219,7 @@ namespace Ryujinx.Core.OsHle.Handles
RunThread(NewThread);
}
TryResumingExecution(SchedThread);
Resume(Thread);
}
}

View file

@ -11,8 +11,6 @@ namespace Ryujinx.Core.OsHle.Handles
public bool IsActive { get; set; }
public bool NeedsReschedule { get; set; }
public AutoResetEvent WaitSync { get; private set; }
public ManualResetEvent WaitActivity { get; private set; }
public AutoResetEvent WaitSched { get; private set; }

View file

@ -63,7 +63,7 @@ namespace Ryujinx.Core.OsHle.Handles
{
KThread Thread = Curr.Thread;
if (Thread.ActualPriority <= MinPriority && (Thread.CoreMask & CoreMask) != 0)
if (Thread.ActualPriority < MinPriority && (Thread.CoreMask & CoreMask) != 0)
{
if (Prev != null)
{

View file

@ -217,7 +217,6 @@ namespace Ryujinx.Core.OsHle.Kernel
UpdateMutexOwner(CurrThread, OwnerThread, MutexAddress);
CurrThread.UpdatePriority();
OwnerThread.UpdatePriority();
int HasListeners = OwnerThread.MutexWaiters.Count > 0 ? MutexHasListenersMask : 0;