summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.h
diff options
context:
space:
mode:
authorGravatar bunnei2017-10-09 23:56:20 -0400
committerGravatar bunnei2017-10-09 23:56:20 -0400
commitb1d5db1cf60344b6b081c9d03cb6ccc3264326cd (patch)
treefde377c4ba3c0f92c032e6f5ec8627aae37270ef /src/core/hle/kernel/thread.h
parentloader: Various improvements for NSO/NRO loaders. (diff)
parentMerge pull request #2996 from MerryMage/split-travis (diff)
downloadyuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.tar.gz
yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.tar.xz
yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.zip
Merge remote-tracking branch 'upstream/master' into nx
# Conflicts: # src/core/CMakeLists.txt # src/core/arm/dynarmic/arm_dynarmic.cpp # src/core/arm/dyncom/arm_dyncom.cpp # src/core/hle/kernel/process.cpp # src/core/hle/kernel/thread.cpp # src/core/hle/kernel/thread.h # src/core/hle/kernel/vm_manager.cpp # src/core/loader/3dsx.cpp # src/core/loader/elf.cpp # src/core/loader/ncch.cpp # src/core/memory.cpp # src/core/memory.h # src/core/memory_setup.h
Diffstat (limited to 'src/core/hle/kernel/thread.h')
-rw-r--r--src/core/hle/kernel/thread.h48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index 2cadb91db..fafcab156 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -15,7 +15,7 @@
15#include "core/hle/kernel/wait_object.h" 15#include "core/hle/kernel/wait_object.h"
16#include "core/hle/result.h" 16#include "core/hle/result.h"
17 17
18enum ThreadPriority : s32 { 18enum ThreadPriority : u32 {
19 THREADPRIO_HIGHEST = 0, ///< Highest thread priority 19 THREADPRIO_HIGHEST = 0, ///< Highest thread priority
20 THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps 20 THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps
21 THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps 21 THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps
@@ -41,6 +41,11 @@ enum ThreadStatus {
41 THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated 41 THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated
42}; 42};
43 43
44enum class ThreadWakeupReason {
45 Signal, // The thread was woken up by WakeupAllWaitingThreads due to an object signal.
46 Timeout // The thread was woken up due to a wait timeout.
47};
48
44namespace Kernel { 49namespace Kernel {
45 50
46class Mutex; 51class Mutex;
@@ -56,10 +61,12 @@ public:
56 * @param arg User data to pass to the thread 61 * @param arg User data to pass to the thread
57 * @param processor_id The ID(s) of the processors on which the thread is desired to be run 62 * @param processor_id The ID(s) of the processors on which the thread is desired to be run
58 * @param stack_top The address of the thread's stack top 63 * @param stack_top The address of the thread's stack top
64 * @param owner_process The parent process for the thread
59 * @return A shared pointer to the newly created thread 65 * @return A shared pointer to the newly created thread
60 */ 66 */
61 static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, u32 priority, 67 static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, u32 priority,
62 u32 arg, s32 processor_id, VAddr stack_top); 68 u32 arg, s32 processor_id, VAddr stack_top,
69 SharedPtr<Process> owner_process);
63 70
64 std::string GetName() const override { 71 std::string GetName() const override {
65 return name; 72 return name;
@@ -80,7 +87,7 @@ public:
80 * Gets the thread's current priority 87 * Gets the thread's current priority
81 * @return The current thread's priority 88 * @return The current thread's priority
82 */ 89 */
83 s32 GetPriority() const { 90 u32 GetPriority() const {
84 return current_priority; 91 return current_priority;
85 } 92 }
86 93
@@ -88,7 +95,7 @@ public:
88 * Sets the thread's current priority 95 * Sets the thread's current priority
89 * @param priority The new priority 96 * @param priority The new priority
90 */ 97 */
91 void SetPriority(s32 priority); 98 void SetPriority(u32 priority);
92 99
93 /** 100 /**
94 * Boost's a thread's priority to the best priority among the thread's held mutexes. 101 * Boost's a thread's priority to the best priority among the thread's held mutexes.
@@ -100,7 +107,7 @@ public:
100 * Temporarily boosts the thread's priority until the next time it is scheduled 107 * Temporarily boosts the thread's priority until the next time it is scheduled
101 * @param priority The new priority 108 * @param priority The new priority
102 */ 109 */
103 void BoostPriority(s32 priority); 110 void BoostPriority(u32 priority);
104 111
105 /** 112 /**
106 * Gets the thread's thread ID 113 * Gets the thread's thread ID
@@ -116,9 +123,9 @@ public:
116 void ResumeFromWait(); 123 void ResumeFromWait();
117 124
118 /** 125 /**
119 * Schedules an event to wake up the specified thread after the specified delay 126 * Schedules an event to wake up the specified thread after the specified delay
120 * @param nanoseconds The time this thread will be allowed to sleep for 127 * @param nanoseconds The time this thread will be allowed to sleep for
121 */ 128 */
122 void WakeAfterDelay(s64 nanoseconds); 129 void WakeAfterDelay(s64 nanoseconds);
123 130
124 /** 131 /**
@@ -157,6 +164,12 @@ public:
157 return tls_address; 164 return tls_address;
158 } 165 }
159 166
167 /*
168 * Returns the address of the current thread's command buffer, located in the TLS.
169 * @returns VAddr of the thread's command buffer.
170 */
171 VAddr GetCommandBufferAddress() const;
172
160 /** 173 /**
161 * Returns whether this thread is waiting for all the objects in 174 * Returns whether this thread is waiting for all the objects in
162 * its wait list to become ready, as a result of a WaitSynchronizationN call 175 * its wait list to become ready, as a result of a WaitSynchronizationN call
@@ -174,8 +187,8 @@ public:
174 VAddr entry_point; 187 VAddr entry_point;
175 VAddr stack_top; 188 VAddr stack_top;
176 189
177 s32 nominal_priority; ///< Nominal thread priority, as set by the emulated application 190 u32 nominal_priority; ///< Nominal thread priority, as set by the emulated application
178 s32 current_priority; ///< Current thread priority, can be temporarily changed 191 u32 current_priority; ///< Current thread priority, can be temporarily changed
179 192
180 u64 last_running_ticks; ///< CPU tick when thread was last running 193 u64 last_running_ticks; ///< CPU tick when thread was last running
181 194
@@ -197,14 +210,18 @@ public:
197 210
198 VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address 211 VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address
199 212
200 /// True if the WaitSynchronizationN output parameter should be set on thread wakeup.
201 bool wait_set_output;
202
203 std::string name; 213 std::string name;
204 214
205 /// Handle used as userdata to reference this object when inserting into the CoreTiming queue. 215 /// Handle used as userdata to reference this object when inserting into the CoreTiming queue.
206 Handle callback_handle; 216 Handle callback_handle;
207 217
218 using WakeupCallback = void(ThreadWakeupReason reason, SharedPtr<Thread> thread,
219 SharedPtr<WaitObject> object);
220 // Callback that will be invoked when the thread is resumed from a waiting state. If the thread
221 // was waiting via WaitSynchronizationN then the object will be the last object that became
222 // available. In case of a timeout, the object will be nullptr.
223 std::function<WakeupCallback> wakeup_callback;
224
208private: 225private:
209 Thread(); 226 Thread();
210 ~Thread() override; 227 ~Thread() override;
@@ -214,9 +231,10 @@ private:
214 * Sets up the primary application thread 231 * Sets up the primary application thread
215 * @param entry_point The address at which the thread should start execution 232 * @param entry_point The address at which the thread should start execution
216 * @param priority The priority to give the main thread 233 * @param priority The priority to give the main thread
234 * @param owner_process The parent process for the main thread
217 * @return A shared pointer to the main thread 235 * @return A shared pointer to the main thread
218 */ 236 */
219SharedPtr<Thread> SetupMainThread(VAddr entry_point, s32 priority); 237SharedPtr<Thread> SetupMainThread(u32 entry_point, u32 priority, SharedPtr<Process> owner_process);
220 238
221/** 239/**
222 * Returns whether there are any threads that are ready to run. 240 * Returns whether there are any threads that are ready to run.
@@ -276,4 +294,4 @@ void ThreadingShutdown();
276 */ 294 */
277const std::vector<SharedPtr<Thread>>& GetThreadList(); 295const std::vector<SharedPtr<Thread>>& GetThreadList();
278 296
279} // namespace 297} // namespace Kernel