summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/thread.h')
-rw-r--r--src/core/hle/kernel/thread.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index d6299364a..633bb7c98 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -7,6 +7,8 @@
7#include <string> 7#include <string>
8#include <vector> 8#include <vector>
9 9
10#include <boost/container/flat_set.hpp>
11
10#include "common/common_types.h" 12#include "common/common_types.h"
11 13
12#include "core/core.h" 14#include "core/core.h"
@@ -40,6 +42,8 @@ enum ThreadStatus {
40 42
41namespace Kernel { 43namespace Kernel {
42 44
45class Mutex;
46
43class Thread final : public WaitObject { 47class Thread final : public WaitObject {
44public: 48public:
45 static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, s32 priority, 49 static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, s32 priority,
@@ -78,6 +82,12 @@ public:
78 void ResumeFromWait(); 82 void ResumeFromWait();
79 83
80 /** 84 /**
85 * Schedules an event to wake up the specified thread after the specified delay.
86 * @param nanoseconds The time this thread will be allowed to sleep for.
87 */
88 void WakeAfterDelay(s64 nanoseconds);
89
90 /**
81 * Sets the result after the thread awakens (from either WaitSynchronization SVC) 91 * Sets the result after the thread awakens (from either WaitSynchronization SVC)
82 * @param result Value to set to the returned result 92 * @param result Value to set to the returned result
83 */ 93 */
@@ -103,8 +113,10 @@ public:
103 113
104 s32 processor_id; 114 s32 processor_id;
105 115
106 std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on 116 /// Mutexes currently held by this thread, which will be released when it exits.
117 boost::container::flat_set<SharedPtr<Mutex>> held_mutexes;
107 118
119 std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on
108 VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address 120 VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address
109 bool wait_all; ///< True if the thread is waiting on all objects before resuming 121 bool wait_all; ///< True if the thread is waiting on all objects before resuming
110 bool wait_set_output; ///< True if the output parameter should be set on thread wakeup 122 bool wait_set_output; ///< True if the output parameter should be set on thread wakeup
@@ -115,9 +127,15 @@ public:
115 bool idle = false; 127 bool idle = false;
116 128
117private: 129private:
118 Thread() = default; 130 Thread();
131 ~Thread() override;
132
133 /// Handle used as userdata to reference this object when inserting into the CoreTiming queue.
134 Handle callback_handle;
119}; 135};
120 136
137extern SharedPtr<Thread> g_main_thread;
138
121/// Sets up the primary application thread 139/// Sets up the primary application thread
122SharedPtr<Thread> SetupMainThread(s32 priority, u32 stack_size); 140SharedPtr<Thread> SetupMainThread(s32 priority, u32 stack_size);
123 141
@@ -151,19 +169,12 @@ void WaitCurrentThread_WaitSynchronization(SharedPtr<WaitObject> wait_object, bo
151void WaitCurrentThread_ArbitrateAddress(VAddr wait_address); 169void WaitCurrentThread_ArbitrateAddress(VAddr wait_address);
152 170
153/** 171/**
154 * Schedules an event to wake up the specified thread after the specified delay.
155 * @param handle The thread handle.
156 * @param nanoseconds The time this thread will be allowed to sleep for.
157 */
158void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds);
159
160/**
161 * Sets up the idle thread, this is a thread that is intended to never execute instructions, 172 * Sets up the idle thread, this is a thread that is intended to never execute instructions,
162 * only to advance the timing. It is scheduled when there are no other ready threads in the thread queue 173 * only to advance the timing. It is scheduled when there are no other ready threads in the thread queue
163 * and will try to yield on every call. 174 * and will try to yield on every call.
164 * @returns The handle of the idle thread 175 * @returns The handle of the idle thread
165 */ 176 */
166Handle SetupIdleThread(); 177SharedPtr<Thread> SetupIdleThread();
167 178
168/// Initialize threading 179/// Initialize threading
169void ThreadingInit(); 180void ThreadingInit();