summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/scheduler.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-10-28 09:38:48 +0100
committerGitHub <noreply@github.com>2018-10-28 09:38:48 +0100
commit2239d4711288ffb61c9ac25ce19e3b6b1e15107f (patch)
tree90cd62acff8b352bfbdb796e8e947416cb8496f5 /src/core/hle/kernel/scheduler.h
parentMerge pull request #1581 from FreddyFunk/macosx-target-version (diff)
parentsvc: Localize the GetInfo enum class to the function itself (diff)
downloadyuzu-2239d4711288ffb61c9ac25ce19e3b6b1e15107f.tar
yuzu-2239d4711288ffb61c9ac25ce19e3b6b1e15107f.tar.gz
yuzu-2239d4711288ffb61c9ac25ce19e3b6b1e15107f.tar.bz2
yuzu-2239d4711288ffb61c9ac25ce19e3b6b1e15107f.tar.lz
yuzu-2239d4711288ffb61c9ac25ce19e3b6b1e15107f.tar.xz
yuzu-2239d4711288ffb61c9ac25ce19e3b6b1e15107f.tar.zst
yuzu-2239d4711288ffb61c9ac25ce19e3b6b1e15107f.zip
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;
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;
};