summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index e15590c49..35ff9a379 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -71,17 +71,17 @@ public:
71}; 71};
72 72
73// Lists all thread ids that aren't deleted/etc. 73// Lists all thread ids that aren't deleted/etc.
74std::vector<Handle> g_thread_queue; 74static std::vector<Handle> thread_queue;
75 75
76// Lists only ready thread ids. 76// Lists only ready thread ids.
77Common::ThreadQueueList<Handle> g_thread_ready_queue; 77static Common::ThreadQueueList<Handle> thread_ready_queue;
78 78
79Handle g_current_thread_handle; 79static Handle current_thread_handle;
80Thread* g_current_thread; 80static Thread* current_thread;
81 81
82/// Gets the current thread 82/// Gets the current thread
83inline Thread* GetCurrentThread() { 83inline Thread* GetCurrentThread() {
84 return g_current_thread; 84 return current_thread;
85} 85}
86 86
87/// Gets the current thread handle 87/// Gets the current thread handle
@@ -91,8 +91,8 @@ Handle GetCurrentThreadHandle() {
91 91
92/// Sets the current thread 92/// Sets the current thread
93inline void SetCurrentThread(Thread* t) { 93inline void SetCurrentThread(Thread* t) {
94 g_current_thread = t; 94 current_thread = t;
95 g_current_thread_handle = t->GetHandle(); 95 current_thread_handle = t->GetHandle();
96} 96}
97 97
98/// Saves the current CPU context 98/// Saves the current CPU context
@@ -131,13 +131,13 @@ void ChangeReadyState(Thread* t, bool ready) {
131 Handle handle = t->GetHandle(); 131 Handle handle = t->GetHandle();
132 if (t->IsReady()) { 132 if (t->IsReady()) {
133 if (!ready) { 133 if (!ready) {
134 g_thread_ready_queue.remove(t->current_priority, handle); 134 thread_ready_queue.remove(t->current_priority, handle);
135 } 135 }
136 } else if (ready) { 136 } else if (ready) {
137 if (t->IsRunning()) { 137 if (t->IsRunning()) {
138 g_thread_ready_queue.push_front(t->current_priority, handle); 138 thread_ready_queue.push_front(t->current_priority, handle);
139 } else { 139 } else {
140 g_thread_ready_queue.push_back(t->current_priority, handle); 140 thread_ready_queue.push_back(t->current_priority, handle);
141 } 141 }
142 t->status = THREADSTATUS_READY; 142 t->status = THREADSTATUS_READY;
143 } 143 }
@@ -195,7 +195,7 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) {
195 s32 priority = THREADPRIO_LOWEST; 195 s32 priority = THREADPRIO_LOWEST;
196 196
197 // Iterate through threads, find highest priority thread that is waiting to be arbitrated... 197 // Iterate through threads, find highest priority thread that is waiting to be arbitrated...
198 for (const auto& handle : g_thread_queue) { 198 for (const auto& handle : thread_queue) {
199 199
200 // TODO(bunnei): Verify arbiter address... 200 // TODO(bunnei): Verify arbiter address...
201 if (!VerifyWait(handle, WAITTYPE_ARB, arbiter)) 201 if (!VerifyWait(handle, WAITTYPE_ARB, arbiter))
@@ -218,7 +218,7 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) {
218void ArbitrateAllThreads(u32 arbiter, u32 address) { 218void ArbitrateAllThreads(u32 arbiter, u32 address) {
219 219
220 // Iterate through threads, find highest priority thread that is waiting to be arbitrated... 220 // Iterate through threads, find highest priority thread that is waiting to be arbitrated...
221 for (const auto& handle : g_thread_queue) { 221 for (const auto& handle : thread_queue) {
222 222
223 // TODO(bunnei): Verify arbiter address... 223 // TODO(bunnei): Verify arbiter address...
224 if (VerifyWait(handle, WAITTYPE_ARB, arbiter)) 224 if (VerifyWait(handle, WAITTYPE_ARB, arbiter))
@@ -265,9 +265,9 @@ Thread* NextThread() {
265 Thread* cur = GetCurrentThread(); 265 Thread* cur = GetCurrentThread();
266 266
267 if (cur && cur->IsRunning()) { 267 if (cur && cur->IsRunning()) {
268 next = g_thread_ready_queue.pop_first_better(cur->current_priority); 268 next = thread_ready_queue.pop_first_better(cur->current_priority);
269 } else { 269 } else {
270 next = g_thread_ready_queue.pop_first(); 270 next = thread_ready_queue.pop_first();
271 } 271 }
272 if (next == 0) { 272 if (next == 0) {
273 return nullptr; 273 return nullptr;
@@ -306,9 +306,9 @@ void DebugThreadQueue() {
306 return; 306 return;
307 } 307 }
308 INFO_LOG(KERNEL, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThreadHandle()); 308 INFO_LOG(KERNEL, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThreadHandle());
309 for (u32 i = 0; i < g_thread_queue.size(); i++) { 309 for (u32 i = 0; i < thread_queue.size(); i++) {
310 Handle handle = g_thread_queue[i]; 310 Handle handle = thread_queue[i];
311 s32 priority = g_thread_ready_queue.contains(handle); 311 s32 priority = thread_ready_queue.contains(handle);
312 if (priority != -1) { 312 if (priority != -1) {
313 INFO_LOG(KERNEL, "0x%02X 0x%08X", priority, handle); 313 INFO_LOG(KERNEL, "0x%02X 0x%08X", priority, handle);
314 } 314 }
@@ -326,8 +326,8 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio
326 326
327 handle = Kernel::g_object_pool.Create(thread); 327 handle = Kernel::g_object_pool.Create(thread);
328 328
329 g_thread_queue.push_back(handle); 329 thread_queue.push_back(handle);
330 g_thread_ready_queue.prepare(priority); 330 thread_ready_queue.prepare(priority);
331 331
332 thread->status = THREADSTATUS_DORMANT; 332 thread->status = THREADSTATUS_DORMANT;
333 thread->entry_point = entry_point; 333 thread->entry_point = entry_point;
@@ -405,16 +405,16 @@ Result SetThreadPriority(Handle handle, s32 priority) {
405 405
406 // Change thread priority 406 // Change thread priority
407 s32 old = thread->current_priority; 407 s32 old = thread->current_priority;
408 g_thread_ready_queue.remove(old, handle); 408 thread_ready_queue.remove(old, handle);
409 thread->current_priority = priority; 409 thread->current_priority = priority;
410 g_thread_ready_queue.prepare(thread->current_priority); 410 thread_ready_queue.prepare(thread->current_priority);
411 411
412 // Change thread status to "ready" and push to ready queue 412 // Change thread status to "ready" and push to ready queue
413 if (thread->IsRunning()) { 413 if (thread->IsRunning()) {
414 thread->status = (thread->status & ~THREADSTATUS_RUNNING) | THREADSTATUS_READY; 414 thread->status = (thread->status & ~THREADSTATUS_RUNNING) | THREADSTATUS_READY;
415 } 415 }
416 if (thread->IsReady()) { 416 if (thread->IsReady()) {
417 g_thread_ready_queue.push_back(thread->current_priority, handle); 417 thread_ready_queue.push_back(thread->current_priority, handle);
418 } 418 }
419 419
420 return 0; 420 return 0;