summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.h
diff options
context:
space:
mode:
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:
217 return is_64bit_process; 217 return is_64bit_process;
218 } 218 }
219 219
220 [[nodiscard]] bool IsSuspended() const {
221 return is_suspended;
222 }
223
224 void SetSuspended(bool suspended) {
225 is_suspended = suspended;
226 }
227
220 /// Gets the total running time of the process instance in ticks. 228 /// Gets the total running time of the process instance in ticks.
221 u64 GetCPUTimeTicks() const { 229 u64 GetCPUTimeTicks() const {
222 return total_process_running_time_ticks; 230 return total_process_running_time_ticks;
@@ -237,6 +245,33 @@ public:
237 ++schedule_count; 245 ++schedule_count;
238 } 246 }
239 247
248 void IncrementThreadCount();
249 void DecrementThreadCount();
250
251 void SetRunningThread(s32 core, KThread* thread, u64 idle_count) {
252 running_threads[core] = thread;
253 running_thread_idle_counts[core] = idle_count;
254 }
255
256 void ClearRunningThread(KThread* thread) {
257 for (size_t i = 0; i < running_threads.size(); ++i) {
258 if (running_threads[i] == thread) {
259 running_threads[i] = nullptr;
260 }
261 }
262 }
263
264 [[nodiscard]] KThread* GetRunningThread(s32 core) const {
265 return running_threads[core];
266 }
267
268 bool ReleaseUserException(KThread* thread);
269
270 [[nodiscard]] KThread* GetPinnedThread(s32 core_id) const {
271 ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
272 return pinned_threads[core_id];
273 }
274
240 /// Gets 8 bytes of random data for svcGetInfo RandomEntropy 275 /// Gets 8 bytes of random data for svcGetInfo RandomEntropy
241 u64 GetRandomEntropy(std::size_t index) const { 276 u64 GetRandomEntropy(std::size_t index) const {
242 return random_entropy.at(index); 277 return random_entropy.at(index);
@@ -310,6 +345,9 @@ public:
310 345
311 void Finalize() override {} 346 void Finalize() override {}
312 347
348 void PinCurrentThread();
349 void UnpinCurrentThread();
350
313 /////////////////////////////////////////////////////////////////////////////////////////////// 351 ///////////////////////////////////////////////////////////////////////////////////////////////
314 // Thread-local storage management 352 // Thread-local storage management
315 353
@@ -320,6 +358,20 @@ public:
320 void FreeTLSRegion(VAddr tls_address); 358 void FreeTLSRegion(VAddr tls_address);
321 359
322private: 360private:
361 void PinThread(s32 core_id, KThread* thread) {
362 ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
363 ASSERT(thread != nullptr);
364 ASSERT(pinned_threads[core_id] == nullptr);
365 pinned_threads[core_id] = thread;
366 }
367
368 void UnpinThread(s32 core_id, KThread* thread) {
369 ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
370 ASSERT(thread != nullptr);
371 ASSERT(pinned_threads[core_id] == thread);
372 pinned_threads[core_id] = nullptr;
373 }
374
323 /// Changes the process status. If the status is different 375 /// Changes the process status. If the status is different
324 /// from the current process status, then this will trigger 376 /// from the current process status, then this will trigger
325 /// a process signal. 377 /// a process signal.
@@ -408,6 +460,17 @@ private:
408 s64 schedule_count{}; 460 s64 schedule_count{};
409 461
410 bool is_signaled{}; 462 bool is_signaled{};
463 bool is_suspended{};
464
465 std::atomic<s32> num_created_threads{};
466 std::atomic<u16> num_threads{};
467 u16 peak_num_threads{};
468
469 std::array<KThread*, Core::Hardware::NUM_CPU_CORES> running_threads{};
470 std::array<u64, Core::Hardware::NUM_CPU_CORES> running_thread_idle_counts{};
471 std::array<KThread*, Core::Hardware::NUM_CPU_CORES> pinned_threads{};
472
473 KThread* exception_thread{};
411 474
412 /// System context 475 /// System context
413 Core::System& system; 476 Core::System& system;