mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-08 07:18:39 +00:00
932224f051
* Implement ARM exclusive load/store with compare exchange insts, and enable multicore by default * Fix comment typo * Support Linux and OSX on MemoryAlloc and CompareExchange128, some cleanup * Use intel syntax on assembly code * Adjust identation * Add CPUID check and fix exclusive reservation granule size * Update schema multicore scheduling default value * Make the cpu id check code lower case aswell
79 lines
2.2 KiB
C#
79 lines
2.2 KiB
C#
using Ryujinx.Common;
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|
{
|
|
class KCoreContext
|
|
{
|
|
private KScheduler _scheduler;
|
|
|
|
private HleCoreManager _coreManager;
|
|
|
|
public bool ContextSwitchNeeded { get; private set; }
|
|
|
|
public long LastContextSwitchTime { get; private set; }
|
|
|
|
public long TotalIdleTimeTicks { get; private set; } //TODO
|
|
|
|
public KThread CurrentThread { get; private set; }
|
|
public KThread SelectedThread { get; private set; }
|
|
|
|
public KCoreContext(KScheduler scheduler, HleCoreManager coreManager)
|
|
{
|
|
_scheduler = scheduler;
|
|
_coreManager = coreManager;
|
|
}
|
|
|
|
public void SelectThread(KThread thread)
|
|
{
|
|
SelectedThread = thread;
|
|
|
|
if (SelectedThread != CurrentThread)
|
|
{
|
|
ContextSwitchNeeded = true;
|
|
}
|
|
}
|
|
|
|
public void UpdateCurrentThread()
|
|
{
|
|
ContextSwitchNeeded = false;
|
|
|
|
LastContextSwitchTime = PerformanceCounter.ElapsedMilliseconds;
|
|
|
|
CurrentThread = SelectedThread;
|
|
|
|
if (CurrentThread != null)
|
|
{
|
|
long currentTime = PerformanceCounter.ElapsedMilliseconds;
|
|
|
|
CurrentThread.TotalTimeRunning += currentTime - CurrentThread.LastScheduledTime;
|
|
CurrentThread.LastScheduledTime = currentTime;
|
|
}
|
|
}
|
|
|
|
public void ContextSwitch()
|
|
{
|
|
ContextSwitchNeeded = false;
|
|
|
|
LastContextSwitchTime = PerformanceCounter.ElapsedMilliseconds;
|
|
|
|
if (CurrentThread != null)
|
|
{
|
|
_coreManager.Reset(CurrentThread.Context.Work);
|
|
}
|
|
|
|
CurrentThread = SelectedThread;
|
|
|
|
if (CurrentThread != null)
|
|
{
|
|
long currentTime = PerformanceCounter.ElapsedMilliseconds;
|
|
|
|
CurrentThread.TotalTimeRunning += currentTime - CurrentThread.LastScheduledTime;
|
|
CurrentThread.LastScheduledTime = currentTime;
|
|
|
|
_coreManager.Set(CurrentThread.Context.Work);
|
|
|
|
CurrentThread.Context.Execute();
|
|
}
|
|
}
|
|
}
|
|
} |