mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-11 05:26:38 +00:00
Fix a specific core migration bug on the scheduler (#2271)
This commit is contained in:
parent
701c427659
commit
ebdbaa6db0
1 changed files with 35 additions and 22 deletions
|
@ -22,8 +22,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
|
|
||||||
private struct SchedulingState
|
private struct SchedulingState
|
||||||
{
|
{
|
||||||
public bool NeedsScheduling;
|
public volatile bool NeedsScheduling;
|
||||||
public KThread SelectedThread;
|
public volatile KThread SelectedThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SchedulingState _state;
|
private SchedulingState _state;
|
||||||
|
@ -349,11 +349,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
|
|
||||||
nextThread ??= _idleThread;
|
nextThread ??= _idleThread;
|
||||||
|
|
||||||
if (currentThread == nextThread)
|
if (currentThread != nextThread)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long previousTicks = LastContextSwitchTime;
|
long previousTicks = LastContextSwitchTime;
|
||||||
long currentTicks = PerformanceCounter.ElapsedTicks;
|
long currentTicks = PerformanceCounter.ElapsedTicks;
|
||||||
long ticksDelta = currentTicks - previousTicks;
|
long ticksDelta = currentTicks - previousTicks;
|
||||||
|
@ -375,6 +372,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
{
|
{
|
||||||
_previousThread = null;
|
_previousThread = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nextThread.CurrentCore != _coreId)
|
if (nextThread.CurrentCore != _coreId)
|
||||||
{
|
{
|
||||||
|
@ -469,6 +467,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
{
|
{
|
||||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||||
|
|
||||||
|
if (!currentThread.IsSchedulable)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
context.CriticalSection.Enter();
|
context.CriticalSection.Enter();
|
||||||
|
|
||||||
if (currentThread.SchedFlags != ThreadSchedState.Running)
|
if (currentThread.SchedFlags != ThreadSchedState.Running)
|
||||||
|
@ -491,6 +494,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
{
|
{
|
||||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||||
|
|
||||||
|
if (!currentThread.IsSchedulable)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
context.CriticalSection.Enter();
|
context.CriticalSection.Enter();
|
||||||
|
|
||||||
if (currentThread.SchedFlags != ThreadSchedState.Running)
|
if (currentThread.SchedFlags != ThreadSchedState.Running)
|
||||||
|
@ -550,6 +558,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
{
|
{
|
||||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||||
|
|
||||||
|
if (!currentThread.IsSchedulable)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
context.CriticalSection.Enter();
|
context.CriticalSection.Enter();
|
||||||
|
|
||||||
if (currentThread.SchedFlags != ThreadSchedState.Running)
|
if (currentThread.SchedFlags != ThreadSchedState.Running)
|
||||||
|
|
Loading…
Reference in a new issue