summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/scheduler.h
diff options
context:
space:
mode:
authorGravatar Lioncash2018-10-25 18:42:50 -0400
committerGravatar Lioncash2018-10-26 12:49:11 -0400
commit6594853eb112f265fe2354723160c0d4e1cb761a (patch)
tree60e67d4d7f38d8f1fe5bebe01f3ef0d87881c570 /src/core/hle/kernel/scheduler.h
parentMerge pull request #1533 from FernandoS27/lmem (diff)
downloadyuzu-6594853eb112f265fe2354723160c0d4e1cb761a.tar.gz
yuzu-6594853eb112f265fe2354723160c0d4e1cb761a.tar.xz
yuzu-6594853eb112f265fe2354723160c0d4e1cb761a.zip
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.h19
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;
17 17
18namespace Kernel { 18namespace Kernel {
19 19
20class Process;
21
20class Scheduler final { 22class Scheduler final {
21public: 23public:
22 explicit Scheduler(Core::ARM_Interface& cpu_core); 24 explicit Scheduler(Core::ARM_Interface& cpu_core);
@@ -31,6 +33,9 @@ public:
31 /// Gets the current running thread 33 /// Gets the current running thread
32 Thread* GetCurrentThread() const; 34 Thread* GetCurrentThread() const;
33 35
36 /// Gets the timestamp for the last context switch in ticks.
37 u64 GetLastContextSwitchTicks() const;
38
34 /// Adds a new thread to the scheduler 39 /// Adds a new thread to the scheduler
35 void AddThread(SharedPtr<Thread> thread, u32 priority); 40 void AddThread(SharedPtr<Thread> thread, u32 priority);
36 41
@@ -64,6 +69,19 @@ private:
64 */ 69 */
65 void SwitchContext(Thread* new_thread); 70 void SwitchContext(Thread* new_thread);
66 71
72 /**
73 * Called on every context switch to update the internal timestamp
74 * This also updates the running time ticks for the given thread and
75 * process using the following difference:
76 *
77 * ticks += most_recent_ticks - last_context_switch_ticks
78 *
79 * The internal tick timestamp for the scheduler is simply the
80 * most recent tick count retrieved. No special arithmetic is
81 * applied to it.
82 */
83 void UpdateLastContextSwitchTime(Thread* thread, Process* process);
84
67 /// Lists all thread ids that aren't deleted/etc. 85 /// Lists all thread ids that aren't deleted/etc.
68 std::vector<SharedPtr<Thread>> thread_list; 86 std::vector<SharedPtr<Thread>> thread_list;
69 87
@@ -73,6 +91,7 @@ private:
73 SharedPtr<Thread> current_thread = nullptr; 91 SharedPtr<Thread> current_thread = nullptr;
74 92
75 Core::ARM_Interface& cpu_core; 93 Core::ARM_Interface& cpu_core;
94 u64 last_context_switch_time = 0;
76 95
77 static std::mutex scheduler_mutex; 96 static std::mutex scheduler_mutex;
78}; 97};