diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/thread.h | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index f1aa358a4..11ef29888 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <functional> | 8 | #include <functional> |
| 8 | #include <string> | 9 | #include <string> |
| 9 | #include <utility> | 10 | #include <utility> |
| @@ -346,10 +347,11 @@ public: | |||
| 346 | 347 | ||
| 347 | void SetStatus(ThreadStatus new_status); | 348 | void SetStatus(ThreadStatus new_status); |
| 348 | 349 | ||
| 349 | constexpr s64 GetLastScheduledTick() const { | 350 | s64 GetLastScheduledTick() const { |
| 350 | return this->last_scheduled_tick; | 351 | return this->last_scheduled_tick; |
| 351 | } | 352 | } |
| 352 | constexpr void SetLastScheduledTick(s64 tick) { | 353 | |
| 354 | void SetLastScheduledTick(s64 tick) { | ||
| 353 | this->last_scheduled_tick = tick; | 355 | this->last_scheduled_tick = tick; |
| 354 | } | 356 | } |
| 355 | 357 | ||
| @@ -481,7 +483,7 @@ public: | |||
| 481 | return ideal_core; | 483 | return ideal_core; |
| 482 | } | 484 | } |
| 483 | 485 | ||
| 484 | constexpr const KAffinityMask& GetAffinityMask() const { | 486 | const KAffinityMask& GetAffinityMask() const { |
| 485 | return affinity_mask; | 487 | return affinity_mask; |
| 486 | } | 488 | } |
| 487 | 489 | ||
| @@ -490,10 +492,11 @@ public: | |||
| 490 | /// Sleeps this thread for the given amount of nanoseconds. | 492 | /// Sleeps this thread for the given amount of nanoseconds. |
| 491 | ResultCode Sleep(s64 nanoseconds); | 493 | ResultCode Sleep(s64 nanoseconds); |
| 492 | 494 | ||
| 493 | constexpr s64 GetYieldScheduleCount() const { | 495 | s64 GetYieldScheduleCount() const { |
| 494 | return this->schedule_count; | 496 | return this->schedule_count; |
| 495 | } | 497 | } |
| 496 | constexpr void SetYieldScheduleCount(s64 count) { | 498 | |
| 499 | void SetYieldScheduleCount(s64 count) { | ||
| 497 | this->schedule_count = count; | 500 | this->schedule_count = count; |
| 498 | } | 501 | } |
| 499 | 502 | ||
| @@ -570,14 +573,9 @@ public: | |||
| 570 | return has_exited; | 573 | return has_exited; |
| 571 | } | 574 | } |
| 572 | 575 | ||
| 573 | struct QueueEntry { | 576 | class QueueEntry { |
| 574 | private: | ||
| 575 | Thread* prev; | ||
| 576 | Thread* next; | ||
| 577 | |||
| 578 | public: | 577 | public: |
| 579 | constexpr QueueEntry() : prev(nullptr), next(nullptr) { /* ... */ | 578 | constexpr QueueEntry() = default; |
| 580 | } | ||
| 581 | 579 | ||
| 582 | constexpr void Initialize() { | 580 | constexpr void Initialize() { |
| 583 | this->prev = nullptr; | 581 | this->prev = nullptr; |
| @@ -590,18 +588,23 @@ public: | |||
| 590 | constexpr Thread* GetNext() const { | 588 | constexpr Thread* GetNext() const { |
| 591 | return this->next; | 589 | return this->next; |
| 592 | } | 590 | } |
| 593 | constexpr void SetPrev(Thread* t) { | 591 | constexpr void SetPrev(Thread* thread) { |
| 594 | this->prev = t; | 592 | this->prev = thread; |
| 595 | } | 593 | } |
| 596 | constexpr void SetNext(Thread* t) { | 594 | constexpr void SetNext(Thread* thread) { |
| 597 | this->next = t; | 595 | this->next = thread; |
| 598 | } | 596 | } |
| 597 | |||
| 598 | private: | ||
| 599 | Thread* prev{}; | ||
| 600 | Thread* next{}; | ||
| 599 | }; | 601 | }; |
| 600 | 602 | ||
| 601 | constexpr QueueEntry& GetPriorityQueueEntry(s32 core) { | 603 | QueueEntry& GetPriorityQueueEntry(s32 core) { |
| 602 | return this->per_core_priority_queue_entry[core]; | 604 | return this->per_core_priority_queue_entry[core]; |
| 603 | } | 605 | } |
| 604 | constexpr const QueueEntry& GetPriorityQueueEntry(s32 core) const { | 606 | |
| 607 | const QueueEntry& GetPriorityQueueEntry(s32 core) const { | ||
| 605 | return this->per_core_priority_queue_entry[core]; | 608 | return this->per_core_priority_queue_entry[core]; |
| 606 | } | 609 | } |
| 607 | 610 | ||
| @@ -619,9 +622,6 @@ public: | |||
| 619 | disable_count--; | 622 | disable_count--; |
| 620 | } | 623 | } |
| 621 | 624 | ||
| 622 | ThreadStatus status = ThreadStatus::Dormant; | ||
| 623 | u32 scheduling_state = 0; | ||
| 624 | |||
| 625 | private: | 625 | private: |
| 626 | friend class GlobalSchedulerContext; | 626 | friend class GlobalSchedulerContext; |
| 627 | friend class KScheduler; | 627 | friend class KScheduler; |
| @@ -638,6 +638,9 @@ private: | |||
| 638 | ThreadContext64 context_64{}; | 638 | ThreadContext64 context_64{}; |
| 639 | std::shared_ptr<Common::Fiber> host_context{}; | 639 | std::shared_ptr<Common::Fiber> host_context{}; |
| 640 | 640 | ||
| 641 | ThreadStatus status = ThreadStatus::Dormant; | ||
| 642 | u32 scheduling_state = 0; | ||
| 643 | |||
| 641 | u64 thread_id = 0; | 644 | u64 thread_id = 0; |
| 642 | 645 | ||
| 643 | VAddr entry_point = 0; | 646 | VAddr entry_point = 0; |
| @@ -701,7 +704,7 @@ private: | |||
| 701 | 704 | ||
| 702 | KScheduler* scheduler = nullptr; | 705 | KScheduler* scheduler = nullptr; |
| 703 | 706 | ||
| 704 | QueueEntry per_core_priority_queue_entry[Core::Hardware::NUM_CPU_CORES]{}; | 707 | std::array<QueueEntry, Core::Hardware::NUM_CPU_CORES> per_core_priority_queue_entry{}; |
| 705 | 708 | ||
| 706 | u32 ideal_core{0xFFFFFFFF}; | 709 | u32 ideal_core{0xFFFFFFFF}; |
| 707 | KAffinityMask affinity_mask{}; | 710 | KAffinityMask affinity_mask{}; |