summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.h
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-03-29 17:01:46 -0400
committerGravatar FernandoS272019-10-15 11:55:06 -0400
commita1ac0c6cb47e10863b0bfbb1a6aadc71ccc513ab (patch)
treed4476f115b69c74f543f7992006f8e5548cd7f54 /src/core/hle/kernel/thread.h
parentImplement a new Core Scheduler (diff)
downloadyuzu-a1ac0c6cb47e10863b0bfbb1a6aadc71ccc513ab.tar.gz
yuzu-a1ac0c6cb47e10863b0bfbb1a6aadc71ccc513ab.tar.xz
yuzu-a1ac0c6cb47e10863b0bfbb1a6aadc71ccc513ab.zip
Addapt thread class to the new Scheduler
Diffstat (limited to 'src/core/hle/kernel/thread.h')
-rw-r--r--src/core/hle/kernel/thread.h55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index 07e989637..c426a7209 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -75,6 +75,21 @@ enum class ThreadActivity : u32 {
75 Paused = 1, 75 Paused = 1,
76}; 76};
77 77
78enum class ThreadSchedStatus : u32 { None = 0, Paused = 1, Runnable = 2, Exited = 3 };
79
80enum ThreadSchedFlags : u32 {
81 ProcessPauseFlag = 1 << 4,
82 ThreadPauseFlag = 1 << 5,
83 ProcessDebugPauseFlag = 1 << 6,
84 KernelInitPauseFlag = 1 << 8,
85};
86
87enum ThreadSchedMasks : u32 {
88 LowMask = 0x000f,
89 HighMask = 0xfff0,
90 ForcePauseMask = 0x0070,
91};
92
78class Thread final : public WaitObject { 93class Thread final : public WaitObject {
79public: 94public:
80 using MutexWaitingThreads = std::vector<SharedPtr<Thread>>; 95 using MutexWaitingThreads = std::vector<SharedPtr<Thread>>;
@@ -278,6 +293,10 @@ public:
278 return processor_id; 293 return processor_id;
279 } 294 }
280 295
296 void SetProcessorID(s32 new_core) {
297 processor_id = new_core;
298 }
299
281 Process* GetOwnerProcess() { 300 Process* GetOwnerProcess() {
282 return owner_process; 301 return owner_process;
283 } 302 }
@@ -383,11 +402,38 @@ public:
383 /// Sleeps this thread for the given amount of nanoseconds. 402 /// Sleeps this thread for the given amount of nanoseconds.
384 void Sleep(s64 nanoseconds); 403 void Sleep(s64 nanoseconds);
385 404
405 /// Yields this thread without rebalancing loads.
406 void YieldType0();
407
408 /// Yields this thread and does a load rebalancing.
409 void YieldType1();
410
411 /// Yields this thread and if the core is left idle, loads are rebalanced
412 void YieldType2();
413
414 ThreadSchedStatus GetSchedulingStatus() {
415 return static_cast<ThreadSchedStatus>(scheduling_state & ThreadSchedMasks::LowMask);
416 }
417
418 bool IsRunning() const {
419 return is_running;
420 }
421
422 void SetIsRunning(bool value) {
423 is_running = value;
424 }
425
386private: 426private:
387 explicit Thread(KernelCore& kernel); 427 explicit Thread(KernelCore& kernel);
388 ~Thread() override; 428 ~Thread() override;
389 429
390 void ChangeScheduler(); 430 void SetSchedulingStatus(ThreadSchedStatus new_status);
431 void SetCurrentPriority(u32 new_priority);
432 ResultCode SetCoreAndAffinityMask(s32 new_core, u64 new_affinity_mask);
433
434 void AdjustSchedulingOnStatus(u32 old_flags);
435 void AdjustSchedulingOnPriority(u32 old_priority);
436 void AdjustSchedulingOnAffinity(u64 old_affinity_mask, s32 old_core);
391 437
392 Core::ARM_Interface::ThreadContext context{}; 438 Core::ARM_Interface::ThreadContext context{};
393 439
@@ -453,6 +499,13 @@ private:
453 499
454 ThreadActivity activity = ThreadActivity::Normal; 500 ThreadActivity activity = ThreadActivity::Normal;
455 501
502 s32 ideal_core_override = -1;
503 u64 affinity_mask_override = 0x1;
504 u32 affinity_override_count = 0;
505
506 u32 scheduling_state = 0;
507 bool is_running = false;
508
456 std::string name; 509 std::string name;
457}; 510};
458 511