thread.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. // Copyright 2014 Citra Emulator Project / PPSSPP Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <functional>
  6. #include <string>
  7. #include <utility>
  8. #include <vector>
  9. #include "common/common_types.h"
  10. #include "common/spin_lock.h"
  11. #include "core/arm/arm_interface.h"
  12. #include "core/hle/kernel/object.h"
  13. #include "core/hle/kernel/synchronization_object.h"
  14. #include "core/hle/result.h"
  15. namespace Common {
  16. class Fiber;
  17. }
  18. namespace Core {
  19. class ARM_Interface;
  20. class System;
  21. } // namespace Core
  22. namespace Kernel {
  23. class GlobalScheduler;
  24. class KernelCore;
  25. class Process;
  26. class Scheduler;
  27. enum ThreadPriority : u32 {
  28. THREADPRIO_HIGHEST = 0, ///< Highest thread priority
  29. THREADPRIO_MAX_CORE_MIGRATION = 2, ///< Highest priority for a core migration
  30. THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps
  31. THREADPRIO_DEFAULT = 44, ///< Default thread priority for userland apps
  32. THREADPRIO_LOWEST = 63, ///< Lowest thread priority
  33. THREADPRIO_COUNT = 64, ///< Total number of possible thread priorities.
  34. };
  35. enum ThreadType : u32 {
  36. THREADTYPE_USER = 0x1,
  37. THREADTYPE_KERNEL = 0x2,
  38. THREADTYPE_HLE = 0x4,
  39. THREADTYPE_IDLE = 0x8,
  40. THREADTYPE_SUSPEND = 0x10,
  41. };
  42. enum ThreadProcessorId : s32 {
  43. /// Indicates that no particular processor core is preferred.
  44. THREADPROCESSORID_DONT_CARE = -1,
  45. /// Run thread on the ideal core specified by the process.
  46. THREADPROCESSORID_IDEAL = -2,
  47. /// Indicates that the preferred processor ID shouldn't be updated in
  48. /// a core mask setting operation.
  49. THREADPROCESSORID_DONT_UPDATE = -3,
  50. THREADPROCESSORID_0 = 0, ///< Run thread on core 0
  51. THREADPROCESSORID_1 = 1, ///< Run thread on core 1
  52. THREADPROCESSORID_2 = 2, ///< Run thread on core 2
  53. THREADPROCESSORID_3 = 3, ///< Run thread on core 3
  54. THREADPROCESSORID_MAX = 4, ///< Processor ID must be less than this
  55. /// Allowed CPU mask
  56. THREADPROCESSORID_DEFAULT_MASK = (1 << THREADPROCESSORID_0) | (1 << THREADPROCESSORID_1) |
  57. (1 << THREADPROCESSORID_2) | (1 << THREADPROCESSORID_3)
  58. };
  59. enum class ThreadStatus {
  60. Running, ///< Currently running
  61. Ready, ///< Ready to run
  62. Paused, ///< Paused by SetThreadActivity or debug
  63. WaitHLEEvent, ///< Waiting for hle event to finish
  64. WaitSleep, ///< Waiting due to a SleepThread SVC
  65. WaitIPC, ///< Waiting for the reply from an IPC request
  66. WaitSynch, ///< Waiting due to WaitSynchronization
  67. WaitMutex, ///< Waiting due to an ArbitrateLock svc
  68. WaitCondVar, ///< Waiting due to an WaitProcessWideKey svc
  69. WaitArb, ///< Waiting due to a SignalToAddress/WaitForAddress svc
  70. Dormant, ///< Created but not yet made ready
  71. Dead ///< Run to completion, or forcefully terminated
  72. };
  73. enum class ThreadWakeupReason {
  74. Signal, // The thread was woken up by WakeupAllWaitingThreads due to an object signal.
  75. Timeout // The thread was woken up due to a wait timeout.
  76. };
  77. enum class ThreadActivity : u32 {
  78. Normal = 0,
  79. Paused = 1,
  80. };
  81. enum class ThreadSchedStatus : u32 {
  82. None = 0,
  83. Paused = 1,
  84. Runnable = 2,
  85. Exited = 3,
  86. };
  87. enum class ThreadSchedFlags : u32 {
  88. ProcessPauseFlag = 1 << 4,
  89. ThreadPauseFlag = 1 << 5,
  90. ProcessDebugPauseFlag = 1 << 6,
  91. KernelInitPauseFlag = 1 << 8,
  92. };
  93. enum class ThreadSchedMasks : u32 {
  94. LowMask = 0x000f,
  95. HighMask = 0xfff0,
  96. ForcePauseMask = 0x0070,
  97. };
  98. class Thread final : public SynchronizationObject {
  99. public:
  100. explicit Thread(KernelCore& kernel);
  101. ~Thread() override;
  102. using MutexWaitingThreads = std::vector<std::shared_ptr<Thread>>;
  103. using ThreadContext32 = Core::ARM_Interface::ThreadContext32;
  104. using ThreadContext64 = Core::ARM_Interface::ThreadContext64;
  105. using ThreadSynchronizationObjects = std::vector<std::shared_ptr<SynchronizationObject>>;
  106. using WakeupCallback =
  107. std::function<bool(ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
  108. std::shared_ptr<SynchronizationObject> object, std::size_t index)>;
  109. using HLECallback = std::function<bool(std::shared_ptr<Thread> thread)>;
  110. /**
  111. * Creates and returns a new thread. The new thread is immediately scheduled
  112. * @param system The instance of the whole system
  113. * @param name The friendly name desired for the thread
  114. * @param entry_point The address at which the thread should start execution
  115. * @param priority The thread's priority
  116. * @param arg User data to pass to the thread
  117. * @param processor_id The ID(s) of the processors on which the thread is desired to be run
  118. * @param stack_top The address of the thread's stack top
  119. * @param owner_process The parent process for the thread, if null, it's a kernel thread
  120. * @return A shared pointer to the newly created thread
  121. */
  122. static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags,
  123. std::string name, VAddr entry_point,
  124. u32 priority, u64 arg, s32 processor_id,
  125. VAddr stack_top, Process* owner_process);
  126. /**
  127. * Creates and returns a new thread. The new thread is immediately scheduled
  128. * @param system The instance of the whole system
  129. * @param name The friendly name desired for the thread
  130. * @param entry_point The address at which the thread should start execution
  131. * @param priority The thread's priority
  132. * @param arg User data to pass to the thread
  133. * @param processor_id The ID(s) of the processors on which the thread is desired to be run
  134. * @param stack_top The address of the thread's stack top
  135. * @param owner_process The parent process for the thread, if null, it's a kernel thread
  136. * @param thread_start_func The function where the host context will start.
  137. * @param thread_start_parameter The parameter which will passed to host context on init
  138. * @return A shared pointer to the newly created thread
  139. */
  140. static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags,
  141. std::string name, VAddr entry_point,
  142. u32 priority, u64 arg, s32 processor_id,
  143. VAddr stack_top, Process* owner_process,
  144. std::function<void(void*)>&& thread_start_func,
  145. void* thread_start_parameter);
  146. std::string GetName() const override {
  147. return name;
  148. }
  149. void SetName(std::string new_name) {
  150. name = std::move(new_name);
  151. }
  152. std::string GetTypeName() const override {
  153. return "Thread";
  154. }
  155. static constexpr HandleType HANDLE_TYPE = HandleType::Thread;
  156. HandleType GetHandleType() const override {
  157. return HANDLE_TYPE;
  158. }
  159. bool ShouldWait(const Thread* thread) const override;
  160. void Acquire(Thread* thread) override;
  161. bool IsSignaled() const override;
  162. /**
  163. * Gets the thread's current priority
  164. * @return The current thread's priority
  165. */
  166. u32 GetPriority() const {
  167. return current_priority;
  168. }
  169. /**
  170. * Gets the thread's nominal priority.
  171. * @return The current thread's nominal priority.
  172. */
  173. u32 GetNominalPriority() const {
  174. return nominal_priority;
  175. }
  176. /**
  177. * Sets the thread's current priority
  178. * @param priority The new priority
  179. */
  180. void SetPriority(u32 priority);
  181. /// Adds a thread to the list of threads that are waiting for a lock held by this thread.
  182. void AddMutexWaiter(std::shared_ptr<Thread> thread);
  183. /// Removes a thread from the list of threads that are waiting for a lock held by this thread.
  184. void RemoveMutexWaiter(std::shared_ptr<Thread> thread);
  185. /// Recalculates the current priority taking into account priority inheritance.
  186. void UpdatePriority();
  187. /// Changes the core that the thread is running or scheduled to run on.
  188. ResultCode SetCoreAndAffinityMask(s32 new_core, u64 new_affinity_mask);
  189. /**
  190. * Gets the thread's thread ID
  191. * @return The thread's ID
  192. */
  193. u64 GetThreadID() const {
  194. return thread_id;
  195. }
  196. /// Resumes a thread from waiting
  197. void /* deprecated */ ResumeFromWait();
  198. void OnWakeUp();
  199. ResultCode Start();
  200. /// Cancels a waiting operation that this thread may or may not be within.
  201. ///
  202. /// When the thread is within a waiting state, this will set the thread's
  203. /// waiting result to signal a canceled wait. The function will then resume
  204. /// this thread.
  205. ///
  206. void CancelWait();
  207. /**
  208. * Schedules an event to wake up the specified thread after the specified delay
  209. * @param nanoseconds The time this thread will be allowed to sleep for
  210. */
  211. void /* deprecated */ WakeAfterDelay(s64 nanoseconds);
  212. /// Cancel any outstanding wakeup events for this thread
  213. void /* deprecated */ CancelWakeupTimer();
  214. /**
  215. * Sets the result after the thread awakens (from svcWaitSynchronization)
  216. * @param result Value to set to the returned result
  217. */
  218. void /*deprecated*/ SetWaitSynchronizationResult(ResultCode result);
  219. /**
  220. * Sets the output parameter value after the thread awakens (from svcWaitSynchronization)
  221. * @param output Value to set to the output parameter
  222. */
  223. void /*deprecated*/ SetWaitSynchronizationOutput(s32 output);
  224. void SetSynchronizationResults(SynchronizationObject* object, ResultCode result);
  225. Core::ARM_Interface& ArmInterface();
  226. const Core::ARM_Interface& ArmInterface() const;
  227. SynchronizationObject* GetSignalingObject() const {
  228. return signaling_object;
  229. }
  230. ResultCode GetSignalingResult() const {
  231. return signaling_result;
  232. }
  233. /**
  234. * Retrieves the index that this particular object occupies in the list of objects
  235. * that the thread passed to WaitSynchronization, starting the search from the last element.
  236. *
  237. * It is used to set the output index of WaitSynchronization when the thread is awakened.
  238. *
  239. * When a thread wakes up due to an object signal, the kernel will use the index of the last
  240. * matching object in the wait objects list in case of having multiple instances of the same
  241. * object in the list.
  242. *
  243. * @param object Object to query the index of.
  244. */
  245. s32 GetSynchronizationObjectIndex(std::shared_ptr<SynchronizationObject> object) const;
  246. /**
  247. * Stops a thread, invalidating it from further use
  248. */
  249. void Stop();
  250. /*
  251. * Returns the Thread Local Storage address of the current thread
  252. * @returns VAddr of the thread's TLS
  253. */
  254. VAddr GetTLSAddress() const {
  255. return tls_address;
  256. }
  257. /*
  258. * Returns the value of the TPIDR_EL0 Read/Write system register for this thread.
  259. * @returns The value of the TPIDR_EL0 register.
  260. */
  261. u64 GetTPIDR_EL0() const {
  262. return tpidr_el0;
  263. }
  264. /// Sets the value of the TPIDR_EL0 Read/Write system register for this thread.
  265. void SetTPIDR_EL0(u64 value) {
  266. tpidr_el0 = value;
  267. }
  268. /*
  269. * Returns the address of the current thread's command buffer, located in the TLS.
  270. * @returns VAddr of the thread's command buffer.
  271. */
  272. VAddr GetCommandBufferAddress() const;
  273. /// Returns whether this thread is waiting on objects from a WaitSynchronization call.
  274. bool IsSleepingOnWait() const {
  275. return status == ThreadStatus::WaitSynch;
  276. }
  277. ThreadContext32& GetContext32() {
  278. return context_32;
  279. }
  280. const ThreadContext32& GetContext32() const {
  281. return context_32;
  282. }
  283. ThreadContext64& GetContext64() {
  284. return context_64;
  285. }
  286. const ThreadContext64& GetContext64() const {
  287. return context_64;
  288. }
  289. bool IsHLEThread() const {
  290. return (type & THREADTYPE_HLE) != 0;
  291. }
  292. bool IsSuspendThread() const {
  293. return (type & THREADTYPE_SUSPEND) != 0;
  294. }
  295. bool IsIdleThread() const {
  296. return (type & THREADTYPE_IDLE) != 0;
  297. }
  298. bool WasRunning() const {
  299. return was_running;
  300. }
  301. void SetWasRunning(bool value) {
  302. was_running = value;
  303. }
  304. std::shared_ptr<Common::Fiber> GetHostContext() const;
  305. ThreadStatus GetStatus() const {
  306. return status;
  307. }
  308. void SetStatus(ThreadStatus new_status);
  309. u64 GetLastRunningTicks() const {
  310. return last_running_ticks;
  311. }
  312. u64 GetTotalCPUTimeTicks() const {
  313. return total_cpu_time_ticks;
  314. }
  315. void UpdateCPUTimeTicks(u64 ticks) {
  316. total_cpu_time_ticks += ticks;
  317. }
  318. s32 GetProcessorID() const {
  319. return processor_id;
  320. }
  321. void SetProcessorID(s32 new_core) {
  322. processor_id = new_core;
  323. }
  324. Process* GetOwnerProcess() {
  325. return owner_process;
  326. }
  327. const Process* GetOwnerProcess() const {
  328. return owner_process;
  329. }
  330. const ThreadSynchronizationObjects& GetSynchronizationObjects() const {
  331. return *wait_objects;
  332. }
  333. void SetSynchronizationObjects(ThreadSynchronizationObjects* objects) {
  334. wait_objects = objects;
  335. }
  336. void ClearSynchronizationObjects() {
  337. for (const auto& waiting_object : *wait_objects) {
  338. waiting_object->RemoveWaitingThread(SharedFrom(this));
  339. }
  340. wait_objects->clear();
  341. }
  342. /// Determines whether all the objects this thread is waiting on are ready.
  343. bool AllSynchronizationObjectsReady() const;
  344. const MutexWaitingThreads& GetMutexWaitingThreads() const {
  345. return wait_mutex_threads;
  346. }
  347. Thread* GetLockOwner() const {
  348. return lock_owner.get();
  349. }
  350. void SetLockOwner(std::shared_ptr<Thread> owner) {
  351. lock_owner = std::move(owner);
  352. }
  353. VAddr GetCondVarWaitAddress() const {
  354. return condvar_wait_address;
  355. }
  356. void SetCondVarWaitAddress(VAddr address) {
  357. condvar_wait_address = address;
  358. }
  359. VAddr GetMutexWaitAddress() const {
  360. return mutex_wait_address;
  361. }
  362. void SetMutexWaitAddress(VAddr address) {
  363. mutex_wait_address = address;
  364. }
  365. Handle GetWaitHandle() const {
  366. return wait_handle;
  367. }
  368. void SetWaitHandle(Handle handle) {
  369. wait_handle = handle;
  370. }
  371. VAddr GetArbiterWaitAddress() const {
  372. return arb_wait_address;
  373. }
  374. void SetArbiterWaitAddress(VAddr address) {
  375. arb_wait_address = address;
  376. }
  377. bool HasWakeupCallback() const {
  378. return wakeup_callback != nullptr;
  379. }
  380. bool HasHLECallback() const {
  381. return hle_callback != nullptr;
  382. }
  383. void SetWakeupCallback(WakeupCallback callback) {
  384. wakeup_callback = std::move(callback);
  385. }
  386. void SetHLECallback(HLECallback callback) {
  387. hle_callback = std::move(callback);
  388. }
  389. void SetHLETimeEvent(Handle time_event) {
  390. hle_time_event = time_event;
  391. }
  392. void SetHLESyncObject(SynchronizationObject* object) {
  393. hle_object = object;
  394. }
  395. Handle GetHLETimeEvent() const {
  396. return hle_time_event;
  397. }
  398. SynchronizationObject* GetHLESyncObject() const {
  399. return hle_object;
  400. }
  401. void InvalidateWakeupCallback() {
  402. SetWakeupCallback(nullptr);
  403. }
  404. void InvalidateHLECallback() {
  405. SetHLECallback(nullptr);
  406. }
  407. /**
  408. * Invokes the thread's wakeup callback.
  409. *
  410. * @pre A valid wakeup callback has been set. Violating this precondition
  411. * will cause an assertion to trigger.
  412. */
  413. bool InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
  414. std::shared_ptr<SynchronizationObject> object, std::size_t index);
  415. bool InvokeHLECallback(std::shared_ptr<Thread> thread);
  416. u32 GetIdealCore() const {
  417. return ideal_core;
  418. }
  419. u64 GetAffinityMask() const {
  420. return affinity_mask;
  421. }
  422. ResultCode SetActivity(ThreadActivity value);
  423. /// Sleeps this thread for the given amount of nanoseconds.
  424. ResultCode Sleep(s64 nanoseconds);
  425. /// Yields this thread without rebalancing loads.
  426. std::pair<ResultCode, bool> YieldSimple();
  427. /// Yields this thread and does a load rebalancing.
  428. std::pair<ResultCode, bool> YieldAndBalanceLoad();
  429. /// Yields this thread and if the core is left idle, loads are rebalanced
  430. std::pair<ResultCode, bool> YieldAndWaitForLoadBalancing();
  431. void IncrementYieldCount() {
  432. yield_count++;
  433. }
  434. u64 GetYieldCount() const {
  435. return yield_count;
  436. }
  437. ThreadSchedStatus GetSchedulingStatus() const {
  438. return static_cast<ThreadSchedStatus>(scheduling_state &
  439. static_cast<u32>(ThreadSchedMasks::LowMask));
  440. }
  441. bool IsRunnable() const {
  442. return scheduling_state == static_cast<u32>(ThreadSchedStatus::Runnable);
  443. }
  444. bool IsRunning() const {
  445. return is_running;
  446. }
  447. void SetIsRunning(bool value) {
  448. is_running = value;
  449. }
  450. bool IsSyncCancelled() const {
  451. return is_sync_cancelled;
  452. }
  453. void SetSyncCancelled(bool value) {
  454. is_sync_cancelled = value;
  455. }
  456. Handle GetGlobalHandle() const {
  457. return global_handle;
  458. }
  459. bool IsWaitingForArbitration() const {
  460. return waiting_for_arbitration;
  461. }
  462. void WaitForArbitration(bool set) {
  463. waiting_for_arbitration = set;
  464. }
  465. bool IsWaitingSync() const {
  466. return is_waiting_on_sync;
  467. }
  468. void SetWaitingSync(bool is_waiting) {
  469. is_waiting_on_sync = is_waiting;
  470. }
  471. bool IsPendingTermination() const {
  472. return will_be_terminated || GetSchedulingStatus() == ThreadSchedStatus::Exited;
  473. }
  474. bool IsPaused() const {
  475. return pausing_state != 0;
  476. }
  477. bool IsContinuousOnSVC() const {
  478. return is_continuous_on_svc;
  479. }
  480. void SetContinuousOnSVC(bool is_continuous) {
  481. is_continuous_on_svc = is_continuous;
  482. }
  483. bool IsPhantomMode() const {
  484. return is_phantom_mode;
  485. }
  486. void SetPhantomMode(bool phantom) {
  487. is_phantom_mode = phantom;
  488. }
  489. bool HasExited() const {
  490. return has_exited;
  491. }
  492. private:
  493. friend class GlobalScheduler;
  494. friend class Scheduler;
  495. void SetSchedulingStatus(ThreadSchedStatus new_status);
  496. void AddSchedulingFlag(ThreadSchedFlags flag);
  497. void RemoveSchedulingFlag(ThreadSchedFlags flag);
  498. void SetCurrentPriority(u32 new_priority);
  499. void AdjustSchedulingOnAffinity(u64 old_affinity_mask, s32 old_core);
  500. Common::SpinLock context_guard{};
  501. ThreadContext32 context_32{};
  502. ThreadContext64 context_64{};
  503. std::unique_ptr<Core::ARM_Interface> arm_interface{};
  504. std::shared_ptr<Common::Fiber> host_context{};
  505. u64 thread_id = 0;
  506. ThreadStatus status = ThreadStatus::Dormant;
  507. VAddr entry_point = 0;
  508. VAddr stack_top = 0;
  509. ThreadType type;
  510. /// Nominal thread priority, as set by the emulated application.
  511. /// The nominal priority is the thread priority without priority
  512. /// inheritance taken into account.
  513. u32 nominal_priority = 0;
  514. /// Current thread priority. This may change over the course of the
  515. /// thread's lifetime in order to facilitate priority inheritance.
  516. u32 current_priority = 0;
  517. u64 total_cpu_time_ticks = 0; ///< Total CPU running ticks.
  518. u64 last_running_ticks = 0; ///< CPU tick when thread was last running
  519. u64 yield_count = 0; ///< Number of redundant yields carried by this thread.
  520. ///< a redundant yield is one where no scheduling is changed
  521. s32 processor_id = 0;
  522. VAddr tls_address = 0; ///< Virtual address of the Thread Local Storage of the thread
  523. u64 tpidr_el0 = 0; ///< TPIDR_EL0 read/write system register.
  524. /// Process that owns this thread
  525. Process* owner_process;
  526. /// Objects that the thread is waiting on, in the same order as they were
  527. /// passed to WaitSynchronization.
  528. ThreadSynchronizationObjects* wait_objects;
  529. SynchronizationObject* signaling_object;
  530. ResultCode signaling_result{RESULT_SUCCESS};
  531. /// List of threads that are waiting for a mutex that is held by this thread.
  532. MutexWaitingThreads wait_mutex_threads;
  533. /// Thread that owns the lock that this thread is waiting for.
  534. std::shared_ptr<Thread> lock_owner;
  535. /// If waiting on a ConditionVariable, this is the ConditionVariable address
  536. VAddr condvar_wait_address = 0;
  537. /// If waiting on a Mutex, this is the mutex address
  538. VAddr mutex_wait_address = 0;
  539. /// The handle used to wait for the mutex.
  540. Handle wait_handle = 0;
  541. /// If waiting for an AddressArbiter, this is the address being waited on.
  542. VAddr arb_wait_address{0};
  543. bool waiting_for_arbitration{};
  544. /// Handle used as userdata to reference this object when inserting into the CoreTiming queue.
  545. Handle global_handle = 0;
  546. /// Callback that will be invoked when the thread is resumed from a waiting state. If the thread
  547. /// was waiting via WaitSynchronization then the object will be the last object that became
  548. /// available. In case of a timeout, the object will be nullptr. DEPRECATED
  549. WakeupCallback wakeup_callback;
  550. /// Callback for HLE Events
  551. HLECallback hle_callback;
  552. Handle hle_time_event;
  553. SynchronizationObject* hle_object;
  554. Scheduler* scheduler = nullptr;
  555. u32 ideal_core{0xFFFFFFFF};
  556. u64 affinity_mask{0x1};
  557. s32 ideal_core_override = -1;
  558. u64 affinity_mask_override = 0x1;
  559. u32 affinity_override_count = 0;
  560. u32 scheduling_state = 0;
  561. u32 pausing_state = 0;
  562. bool is_running = false;
  563. bool is_waiting_on_sync = false;
  564. bool is_sync_cancelled = false;
  565. bool is_continuous_on_svc = false;
  566. bool will_be_terminated = false;
  567. bool is_phantom_mode = false;
  568. bool has_exited = false;
  569. bool was_running = false;
  570. std::string name;
  571. };
  572. /**
  573. * Gets the current thread
  574. */
  575. Thread* GetCurrentThread();
  576. } // namespace Kernel