0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx.HLE/HOS/Kernel/KCoreContext.cs

66 lines
1.6 KiB
C#
Raw Normal View History

using Ryujinx.Common;
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)
{
Thread.LastScheduledTicks = PerformanceCounter.ElapsedMilliseconds;
}
if (SelectedThread != CurrentThread)
{
ContextSwitchNeeded = true;
}
}
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();
}
}
}
}