KThreadContext.cs
1 using Ryujinx.Cpu; 2 using Ryujinx.Horizon.Common; 3 using System.Threading; 4 5 namespace Ryujinx.HLE.HOS.Kernel.Threading 6 { 7 class KThreadContext : IThreadContext 8 { 9 private readonly IExecutionContext _context; 10 11 public bool Running => _context.Running; 12 public ulong TlsAddress => (ulong)_context.TpidrroEl0; 13 14 public ulong GetX(int index) => _context.GetX(index); 15 16 private int _locked; 17 18 public KThreadContext(IExecutionContext context) 19 { 20 _context = context; 21 } 22 23 public bool Lock() 24 { 25 return Interlocked.Exchange(ref _locked, 1) == 0; 26 } 27 28 public void Unlock() 29 { 30 Interlocked.Exchange(ref _locked, 0); 31 } 32 } 33 }