2023-01-04 14:15:45 -08:00
|
|
|
|
using Ryujinx.Cpu;
|
|
|
|
|
using Ryujinx.Horizon.Common;
|
|
|
|
|
using System.Threading;
|
2020-12-09 14:20:05 -08:00
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|
|
|
|
{
|
2023-01-04 14:15:45 -08:00
|
|
|
|
class KThreadContext : IThreadContext
|
2020-12-09 14:20:05 -08:00
|
|
|
|
{
|
2023-01-04 14:15:45 -08:00
|
|
|
|
private readonly IExecutionContext _context;
|
|
|
|
|
|
|
|
|
|
public bool Running => _context.Running;
|
|
|
|
|
public ulong TlsAddress => (ulong)_context.TpidrroEl0;
|
|
|
|
|
|
|
|
|
|
public ulong GetX(int index) => _context.GetX(index);
|
|
|
|
|
|
2020-12-09 14:20:05 -08:00
|
|
|
|
private int _locked;
|
|
|
|
|
|
2023-01-04 14:15:45 -08:00
|
|
|
|
public KThreadContext(IExecutionContext context)
|
|
|
|
|
{
|
|
|
|
|
_context = context;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-09 14:20:05 -08:00
|
|
|
|
public bool Lock()
|
|
|
|
|
{
|
|
|
|
|
return Interlocked.Exchange(ref _locked, 1) == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Unlock()
|
|
|
|
|
{
|
|
|
|
|
Interlocked.Exchange(ref _locked, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|