2018-10-28 22:31:13 +00:00
|
|
|
using Ryujinx.Common;
|
2018-09-18 23:36:43 +00:00
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel
|
|
|
|
{
|
|
|
|
class KCoreContext
|
|
|
|
{
|
|
|
|
private KScheduler Scheduler;
|
|
|
|
|
|
|
|
private HleCoreManager CoreManager;
|
|
|
|
|
|
|
|
public bool ContextSwitchNeeded { get; private set; }
|
|
|
|
|
|
|
|
public KThread CurrentThread { get; private set; }
|
|
|
|
public KThread SelectedThread { get; private set; }
|
|
|
|
|
|
|
|
public KCoreContext(KScheduler Scheduler, HleCoreManager CoreManager)
|
|
|
|
{
|
|
|
|
this.Scheduler = Scheduler;
|
|
|
|
this.CoreManager = CoreManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SelectThread(KThread Thread)
|
|
|
|
{
|
|
|
|
SelectedThread = Thread;
|
|
|
|
|
|
|
|
if (Thread != null)
|
|
|
|
{
|
2018-10-28 22:31:13 +00:00
|
|
|
Thread.LastScheduledTicks = PerformanceCounter.ElapsedMilliseconds;
|
2018-09-18 23:36:43 +00:00
|
|
|
}
|
|
|
|
|
2018-09-19 15:16:20 +00:00
|
|
|
if (SelectedThread != CurrentThread)
|
|
|
|
{
|
|
|
|
ContextSwitchNeeded = true;
|
|
|
|
}
|
2018-09-18 23:36:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateCurrentThread()
|
|
|
|
{
|
|
|
|
ContextSwitchNeeded = false;
|
|
|
|
|
|
|
|
CurrentThread = SelectedThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ContextSwitch()
|
|
|
|
{
|
|
|
|
ContextSwitchNeeded = false;
|
|
|
|
|
|
|
|
if (CurrentThread != null)
|
|
|
|
{
|
|
|
|
CoreManager.GetThread(CurrentThread.Context.Work).Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
CurrentThread = SelectedThread;
|
|
|
|
|
|
|
|
if (CurrentThread != null)
|
|
|
|
{
|
|
|
|
CurrentThread.ClearExclusive();
|
|
|
|
|
|
|
|
CoreManager.GetThread(CurrentThread.Context.Work).Set();
|
|
|
|
|
|
|
|
CurrentThread.Context.Execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|