summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.h
diff options
context:
space:
mode:
authorGravatar bunnei2016-12-16 00:41:22 -0500
committerGravatar GitHub2016-12-16 00:41:22 -0500
commitcda7210fade53a96fcba5fe5cd6dfd7b604f8277 (patch)
treec4090e3871e717ee4d0a2edd837feffc2c877cb0 /src/core/hle/kernel/thread.h
parentMerge pull request #2316 from endrift/macos-gcc (diff)
parentFixed the codestyle to match our clang-format rules. (diff)
downloadyuzu-cda7210fade53a96fcba5fe5cd6dfd7b604f8277.tar.gz
yuzu-cda7210fade53a96fcba5fe5cd6dfd7b604f8277.tar.xz
yuzu-cda7210fade53a96fcba5fe5cd6dfd7b604f8277.zip
Merge pull request #2260 from Subv/scheduling
Threading: Reworked the way our scheduler works.
Diffstat (limited to 'src/core/hle/kernel/thread.h')
-rw-r--r--src/core/hle/kernel/thread.h44
1 files changed, 35 insertions, 9 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index e0ffcea8a..238359fc5 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -5,7 +5,9 @@
5#pragma once 5#pragma once
6 6
7#include <string> 7#include <string>
8#include <unordered_map>
8#include <vector> 9#include <vector>
10#include <boost/container/flat_map.hpp>
9#include <boost/container/flat_set.hpp> 11#include <boost/container/flat_set.hpp>
10#include "common/common_types.h" 12#include "common/common_types.h"
11#include "core/core.h" 13#include "core/core.h"
@@ -125,6 +127,16 @@ public:
125 void SetWaitSynchronizationOutput(s32 output); 127 void SetWaitSynchronizationOutput(s32 output);
126 128
127 /** 129 /**
130 * Retrieves the index that this particular object occupies in the list of objects
131 * that the thread passed to WaitSynchronizationN.
132 * It is used to set the output value of WaitSynchronizationN when the thread is awakened.
133 * @param object Object to query the index of.
134 */
135 s32 GetWaitObjectIndex(const WaitObject* object) const {
136 return wait_objects_index.at(object->GetObjectId());
137 }
138
139 /**
128 * Stops a thread, invalidating it from further use 140 * Stops a thread, invalidating it from further use
129 */ 141 */
130 void Stop(); 142 void Stop();
@@ -137,6 +149,15 @@ public:
137 return tls_address; 149 return tls_address;
138 } 150 }
139 151
152 /**
153 * Returns whether this thread is waiting for all the objects in
154 * its wait list to become ready, as a result of a WaitSynchronizationN call
155 * with wait_all = true, or a ReplyAndReceive call.
156 */
157 bool IsSleepingOnWaitAll() const {
158 return !wait_objects.empty();
159 }
160
140 Core::ThreadContext context; 161 Core::ThreadContext context;
141 162
142 u32 thread_id; 163 u32 thread_id;
@@ -154,16 +175,22 @@ public:
154 175
155 VAddr tls_address; ///< Virtual address of the Thread Local Storage of the thread 176 VAddr tls_address; ///< Virtual address of the Thread Local Storage of the thread
156 177
157 bool waitsynch_waited; ///< Set to true if the last svcWaitSynch call caused the thread to wait
158
159 /// Mutexes currently held by this thread, which will be released when it exits. 178 /// Mutexes currently held by this thread, which will be released when it exits.
160 boost::container::flat_set<SharedPtr<Mutex>> held_mutexes; 179 boost::container::flat_set<SharedPtr<Mutex>> held_mutexes;
161 180
162 SharedPtr<Process> owner_process; ///< Process that owns this thread 181 SharedPtr<Process> owner_process; ///< Process that owns this thread
163 std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on 182
164 VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address 183 /// Objects that the thread is waiting on.
165 bool wait_all; ///< True if the thread is waiting on all objects before resuming 184 /// This is only populated when the thread should wait for all the objects to become ready.
166 bool wait_set_output; ///< True if the output parameter should be set on thread wakeup 185 std::vector<SharedPtr<WaitObject>> wait_objects;
186
187 /// Mapping of Object ids to their position in the last waitlist that this object waited on.
188 boost::container::flat_map<int, s32> wait_objects_index;
189
190 VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address
191
192 /// True if the WaitSynchronizationN output parameter should be set on thread wakeup.
193 bool wait_set_output;
167 194
168 std::string name; 195 std::string name;
169 196
@@ -215,10 +242,9 @@ void WaitCurrentThread_Sleep();
215 * @param wait_objects Kernel objects that we are waiting on 242 * @param wait_objects Kernel objects that we are waiting on
216 * @param wait_set_output If true, set the output parameter on thread wakeup (for 243 * @param wait_set_output If true, set the output parameter on thread wakeup (for
217 * WaitSynchronizationN only) 244 * WaitSynchronizationN only)
218 * @param wait_all If true, wait on all objects before resuming (for WaitSynchronizationN only)
219 */ 245 */
220void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wait_objects, 246void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wait_objects,
221 bool wait_set_output, bool wait_all); 247 bool wait_set_output);
222 248
223/** 249/**
224 * Waits the current thread from an ArbitrateAddress call 250 * Waits the current thread from an ArbitrateAddress call