2023-01-04 17:15:45 -05:00
|
|
|
|
using Ryujinx.Cpu;
|
|
|
|
|
using Ryujinx.Horizon.Common;
|
|
|
|
|
using System.Threading;
|
2020-12-09 17:20:05 -05:00
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|
|
|
|
{
|
2023-01-04 17:15:45 -05:00
|
|
|
|
class KThreadContext : IThreadContext
|
2020-12-09 17:20:05 -05:00
|
|
|
|
{
|
2023-01-04 17:15:45 -05: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 17:20:05 -05:00
|
|
|
|
private int _locked;
|
|
|
|
|
|
2023-01-04 17:15:45 -05:00
|
|
|
|
public KThreadContext(IExecutionContext context)
|
|
|
|
|
{
|
|
|
|
|
_context = context;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-09 17:20:05 -05:00
|
|
|
|
public bool Lock()
|
|
|
|
|
{
|
|
|
|
|
return Interlocked.Exchange(ref _locked, 1) == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Unlock()
|
|
|
|
|
{
|
|
|
|
|
Interlocked.Exchange(ref _locked, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|