mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-25 15:43:11 +00:00
c1b7340023
* Timing: Optimize Timestamp Aquisition Currently, we make use of Environment.TickCount in a number of places. This has some downsides, mainly being that the TickCount is a signed 32-bit integer, and has an effective limit of ~25 days before overflowing and wrapping around. Due to the signed-ness of the value, this also caused issues with negative numbers. This resolves these issues by using a 64-bit tick count obtained from Performance Counters (via the Stopwatch class). This has a beneficial side effect of being significantly more accurate than the TickCount. * Timing: Rename ElapsedTicks to ElapsedMilliseconds and expose TicksPerX * Timing: Some style changes * Timing: Align static variable initialization
66 lines
1.6 KiB
C#
66 lines
1.6 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|
|
} |