summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/scheduler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/scheduler.h')
-rw-r--r--src/core/hle/kernel/scheduler.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/core/hle/kernel/scheduler.h b/src/core/hle/kernel/scheduler.h
index c63032b7d..97ced4dfc 100644
--- a/src/core/hle/kernel/scheduler.h
+++ b/src/core/hle/kernel/scheduler.h
@@ -51,6 +51,75 @@ public:
51 /// Sets the priority of a thread in the scheduler 51 /// Sets the priority of a thread in the scheduler
52 void SetThreadPriority(Thread* thread, u32 priority); 52 void SetThreadPriority(Thread* thread, u32 priority);
53 53
54 /// Gets the next suggested thread for load balancing
55 Thread* GetNextSuggestedThread(u32 core, u32 minimum_priority) const;
56
57 /**
58 * YieldWithoutLoadBalancing -- analogous to normal yield on a system
59 * Moves the thread to the end of the ready queue for its priority, and then reschedules the
60 * system to the new head of the queue.
61 *
62 * Example (Single Core -- but can be extrapolated to multi):
63 * ready_queue[prio=0]: ThreadA, ThreadB, ThreadC (->exec order->)
64 * Currently Running: ThreadR
65 *
66 * ThreadR calls YieldWithoutLoadBalancing
67 *
68 * ThreadR is moved to the end of ready_queue[prio=0]:
69 * ready_queue[prio=0]: ThreadA, ThreadB, ThreadC, ThreadR (->exec order->)
70 * Currently Running: Nothing
71 *
72 * System is rescheduled (ThreadA is popped off of queue):
73 * ready_queue[prio=0]: ThreadB, ThreadC, ThreadR (->exec order->)
74 * Currently Running: ThreadA
75 *
76 * If the queue is empty at time of call, no yielding occurs. This does not cross between cores
77 * or priorities at all.
78 */
79 void YieldWithoutLoadBalancing(Thread* thread);
80
81 /**
82 * YieldWithLoadBalancing -- yield but with better selection of the new running thread
83 * Moves the current thread to the end of the ready queue for its priority, then selects a
84 * 'suggested thread' (a thread on a different core that could run on this core) from the
85 * scheduler, changes its core, and reschedules the current core to that thread.
86 *
87 * Example (Dual Core -- can be extrapolated to Quad Core, this is just normal yield if it were
88 * single core):
89 * ready_queue[core=0][prio=0]: ThreadA, ThreadB (affinities not pictured as irrelevant
90 * ready_queue[core=1][prio=0]: ThreadC[affinity=both], ThreadD[affinity=core1only]
91 * Currently Running: ThreadQ on Core 0 || ThreadP on Core 1
92 *
93 * ThreadQ calls YieldWithLoadBalancing
94 *
95 * ThreadQ is moved to the end of ready_queue[core=0][prio=0]:
96 * ready_queue[core=0][prio=0]: ThreadA, ThreadB
97 * ready_queue[core=1][prio=0]: ThreadC[affinity=both], ThreadD[affinity=core1only]
98 * Currently Running: ThreadQ on Core 0 || ThreadP on Core 1
99 *
100 * A list of suggested threads for each core is compiled
101 * Suggested Threads: {ThreadC on Core 1}
102 * If this were quad core (as the switch is), there could be between 0 and 3 threads in this
103 * list. If there are more than one, the thread is selected by highest prio.
104 *
105 * ThreadC is core changed to Core 0:
106 * ready_queue[core=0][prio=0]: ThreadC, ThreadA, ThreadB, ThreadQ
107 * ready_queue[core=1][prio=0]: ThreadD
108 * Currently Running: None on Core 0 || ThreadP on Core 1
109 *
110 * System is rescheduled (ThreadC is popped off of queue):
111 * ready_queue[core=0][prio=0]: ThreadA, ThreadB, ThreadQ
112 * ready_queue[core=1][prio=0]: ThreadD
113 * Currently Running: ThreadC on Core 0 || ThreadP on Core 1
114 *
115 * If no suggested threads can be found this will behave just as normal yield. If there are
116 * multiple candidates for the suggested thread on a core, the highest prio is taken.
117 */
118 void YieldWithLoadBalancing(Thread* thread);
119
120 /// Currently unknown -- asserts as unimplemented on call
121 void YieldAndWaitForLoadBalancing(Thread* thread);
122
54 /// Returns a list of all threads managed by the scheduler 123 /// Returns a list of all threads managed by the scheduler
55 const std::vector<SharedPtr<Thread>>& GetThreadList() const { 124 const std::vector<SharedPtr<Thread>>& GetThreadList() const {
56 return thread_list; 125 return thread_list;