diff options
| author | Lioncash <mathew1800@gmail.com> | 2018-10-25 18:42:50 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2018-10-26 12:49:11 -0400 |
| commit | 6594853eb112f265fe2354723160c0d4e1cb761a (patch) | |
| tree | 60e67d4d7f38d8f1fe5bebe01f3ef0d87881c570 /src/core/hle/kernel/scheduler.h | |
| parent | d278f25bda79a2d2ed560a68f3983881c1a1e501 (diff) | |
svc: Implement svcGetInfo command 0xF0000002
This retrieves:
if (curr_thread == handle_thread) {
result = total_thread_ticks + (hardware_tick_count - last_context_switch_ticks);
} else if (curr_thread == handle_thread && sub_id == current_core_index) {
result = hardware_tick_count - last_context_switch_ticks;
}
Diffstat (limited to 'src/core/hle/kernel/scheduler.h')
| -rw-r--r-- | src/core/hle/kernel/scheduler.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/hle/kernel/scheduler.h b/src/core/hle/kernel/scheduler.h index 2c94641ec..c63032b7d 100644 --- a/src/core/hle/kernel/scheduler.h +++ b/src/core/hle/kernel/scheduler.h @@ -17,6 +17,8 @@ class ARM_Interface; namespace Kernel { +class Process; + class Scheduler final { public: explicit Scheduler(Core::ARM_Interface& cpu_core); @@ -31,6 +33,9 @@ public: /// Gets the current running thread Thread* GetCurrentThread() const; + /// Gets the timestamp for the last context switch in ticks. + u64 GetLastContextSwitchTicks() const; + /// Adds a new thread to the scheduler void AddThread(SharedPtr<Thread> thread, u32 priority); @@ -64,6 +69,19 @@ private: */ void SwitchContext(Thread* new_thread); + /** + * Called on every context switch to update the internal timestamp + * This also updates the running time ticks for the given thread and + * process using the following difference: + * + * ticks += most_recent_ticks - last_context_switch_ticks + * + * The internal tick timestamp for the scheduler is simply the + * most recent tick count retrieved. No special arithmetic is + * applied to it. + */ + void UpdateLastContextSwitchTime(Thread* thread, Process* process); + /// Lists all thread ids that aren't deleted/etc. std::vector<SharedPtr<Thread>> thread_list; @@ -73,6 +91,7 @@ private: SharedPtr<Thread> current_thread = nullptr; Core::ARM_Interface& cpu_core; + u64 last_context_switch_time = 0; static std::mutex scheduler_mutex; }; |
