summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-05-02 22:36:51 -0400
committerGravatar bunnei2018-05-10 19:34:46 -0400
commita434fdcb102e96ddf564dc0973d7073d49bf19fc (patch)
treede758b0cc5ebcb67146397a74474fb898c0be51a /src/core/hle/kernel/thread.cpp
parentcore: Create a thread for each CPU core, keep in lock-step with a barrier. (diff)
downloadyuzu-a434fdcb102e96ddf564dc0973d7073d49bf19fc.tar.gz
yuzu-a434fdcb102e96ddf564dc0973d7073d49bf19fc.tar.xz
yuzu-a434fdcb102e96ddf564dc0973d7073d49bf19fc.zip
core: Implement multicore support.
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 1bd5d9ebf..0a5441684 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -64,7 +64,7 @@ void Thread::Stop() {
64 // Clean up thread from ready queue 64 // Clean up thread from ready queue
65 // This is only needed when the thread is termintated forcefully (SVC TerminateProcess) 65 // This is only needed when the thread is termintated forcefully (SVC TerminateProcess)
66 if (status == THREADSTATUS_READY) { 66 if (status == THREADSTATUS_READY) {
67 Core::System::GetInstance().Scheduler().UnscheduleThread(this, current_priority); 67 scheduler->UnscheduleThread(this, current_priority);
68 } 68 }
69 69
70 status = THREADSTATUS_DEAD; 70 status = THREADSTATUS_DEAD;
@@ -92,7 +92,7 @@ void WaitCurrentThread_Sleep() {
92void ExitCurrentThread() { 92void ExitCurrentThread() {
93 Thread* thread = GetCurrentThread(); 93 Thread* thread = GetCurrentThread();
94 thread->Stop(); 94 thread->Stop();
95 Core::System::GetInstance().Scheduler().RemoveThread(thread); 95 Core::System::GetInstance().CurrentScheduler().RemoveThread(thread);
96} 96}
97 97
98/** 98/**
@@ -188,7 +188,7 @@ void Thread::ResumeFromWait() {
188 wakeup_callback = nullptr; 188 wakeup_callback = nullptr;
189 189
190 status = THREADSTATUS_READY; 190 status = THREADSTATUS_READY;
191 Core::System::GetInstance().Scheduler().ScheduleThread(this, current_priority); 191 scheduler->ScheduleThread(this, current_priority);
192 Core::System::GetInstance().PrepareReschedule(); 192 Core::System::GetInstance().PrepareReschedule();
193} 193}
194 194
@@ -259,8 +259,6 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
259 259
260 SharedPtr<Thread> thread(new Thread); 260 SharedPtr<Thread> thread(new Thread);
261 261
262 Core::System::GetInstance().Scheduler().AddThread(thread, priority);
263
264 thread->thread_id = NewThreadId(); 262 thread->thread_id = NewThreadId();
265 thread->status = THREADSTATUS_DORMANT; 263 thread->status = THREADSTATUS_DORMANT;
266 thread->entry_point = entry_point; 264 thread->entry_point = entry_point;
@@ -275,6 +273,8 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
275 thread->name = std::move(name); 273 thread->name = std::move(name);
276 thread->callback_handle = wakeup_callback_handle_table.Create(thread).Unwrap(); 274 thread->callback_handle = wakeup_callback_handle_table.Create(thread).Unwrap();
277 thread->owner_process = owner_process; 275 thread->owner_process = owner_process;
276 thread->scheduler = Core::System().GetInstance().Scheduler(static_cast<size_t>(processor_id));
277 thread->scheduler->AddThread(thread, priority);
278 278
279 // Find the next available TLS index, and mark it as used 279 // Find the next available TLS index, and mark it as used
280 auto& tls_slots = owner_process->tls_slots; 280 auto& tls_slots = owner_process->tls_slots;
@@ -337,7 +337,7 @@ void Thread::SetPriority(u32 priority) {
337} 337}
338 338
339void Thread::BoostPriority(u32 priority) { 339void Thread::BoostPriority(u32 priority) {
340 Core::System::GetInstance().Scheduler().SetThreadPriority(this, priority); 340 scheduler->SetThreadPriority(this, priority);
341 current_priority = priority; 341 current_priority = priority;
342} 342}
343 343
@@ -406,7 +406,7 @@ void Thread::UpdatePriority() {
406 if (new_priority == current_priority) 406 if (new_priority == current_priority)
407 return; 407 return;
408 408
409 Core::System::GetInstance().Scheduler().SetThreadPriority(this, new_priority); 409 scheduler->SetThreadPriority(this, new_priority);
410 410
411 current_priority = new_priority; 411 current_priority = new_priority;
412 412
@@ -421,7 +421,7 @@ void Thread::UpdatePriority() {
421 * Gets the current thread 421 * Gets the current thread
422 */ 422 */
423Thread* GetCurrentThread() { 423Thread* GetCurrentThread() {
424 return Core::System::GetInstance().Scheduler().GetCurrentThread(); 424 return Core::System::GetInstance().CurrentScheduler().GetCurrentThread();
425} 425}
426 426
427void ThreadingInit() { 427void ThreadingInit() {