KThreadContext.cs 757 B

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