summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/process.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-01-20 22:42:27 +0100
committerbunnei <bunneidev@gmail.com>2021-01-29 06:42:26 +0100
commitcdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce (patch)
tree987f6cb5d3f1955dc88f5ac2c1d5c1329d787fc4 /src/core/hle/kernel/process.h
parentkernel: svc_types: Add ThreadActivity. (diff)
downloadyuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar
yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar.gz
yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar.bz2
yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar.lz
yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar.xz
yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar.zst
yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.zip
Diffstat (limited to 'src/core/hle/kernel/process.h')
-rw-r--r--src/core/hle/kernel/process.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index 917babfb4..11d78f3a8 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -217,6 +217,14 @@ public:
return is_64bit_process;
}
+ [[nodiscard]] bool IsSuspended() const {
+ return is_suspended;
+ }
+
+ void SetSuspended(bool suspended) {
+ is_suspended = suspended;
+ }
+
/// Gets the total running time of the process instance in ticks.
u64 GetCPUTimeTicks() const {
return total_process_running_time_ticks;
@@ -237,6 +245,33 @@ public:
++schedule_count;
}
+ void IncrementThreadCount();
+ void DecrementThreadCount();
+
+ void SetRunningThread(s32 core, KThread* thread, u64 idle_count) {
+ running_threads[core] = thread;
+ running_thread_idle_counts[core] = idle_count;
+ }
+
+ void ClearRunningThread(KThread* thread) {
+ for (size_t i = 0; i < running_threads.size(); ++i) {
+ if (running_threads[i] == thread) {
+ running_threads[i] = nullptr;
+ }
+ }
+ }
+
+ [[nodiscard]] KThread* GetRunningThread(s32 core) const {
+ return running_threads[core];
+ }
+
+ bool ReleaseUserException(KThread* thread);
+
+ [[nodiscard]] KThread* GetPinnedThread(s32 core_id) const {
+ ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
+ return pinned_threads[core_id];
+ }
+
/// Gets 8 bytes of random data for svcGetInfo RandomEntropy
u64 GetRandomEntropy(std::size_t index) const {
return random_entropy.at(index);
@@ -310,6 +345,9 @@ public:
void Finalize() override {}
+ void PinCurrentThread();
+ void UnpinCurrentThread();
+
///////////////////////////////////////////////////////////////////////////////////////////////
// Thread-local storage management
@@ -320,6 +358,20 @@ public:
void FreeTLSRegion(VAddr tls_address);
private:
+ void PinThread(s32 core_id, KThread* thread) {
+ ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
+ ASSERT(thread != nullptr);
+ ASSERT(pinned_threads[core_id] == nullptr);
+ pinned_threads[core_id] = thread;
+ }
+
+ void UnpinThread(s32 core_id, KThread* thread) {
+ ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
+ ASSERT(thread != nullptr);
+ ASSERT(pinned_threads[core_id] == thread);
+ pinned_threads[core_id] = nullptr;
+ }
+
/// Changes the process status. If the status is different
/// from the current process status, then this will trigger
/// a process signal.
@@ -408,6 +460,17 @@ private:
s64 schedule_count{};
bool is_signaled{};
+ bool is_suspended{};
+
+ std::atomic<s32> num_created_threads{};
+ std::atomic<u16> num_threads{};
+ u16 peak_num_threads{};
+
+ std::array<KThread*, Core::Hardware::NUM_CPU_CORES> running_threads{};
+ std::array<u64, Core::Hardware::NUM_CPU_CORES> running_thread_idle_counts{};
+ std::array<KThread*, Core::Hardware::NUM_CPU_CORES> pinned_threads{};
+
+ KThread* exception_thread{};
/// System context
Core::System& system;