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.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 63f8923fd..434655638 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -50,7 +50,7 @@ void Thread::Stop() {
50 50
51 // Clean up thread from ready queue 51 // Clean up thread from ready queue
52 // This is only needed when the thread is terminated forcefully (SVC TerminateProcess) 52 // This is only needed when the thread is terminated forcefully (SVC TerminateProcess)
53 if (status == ThreadStatus::Ready) { 53 if (status == ThreadStatus::Ready || status == ThreadStatus::Paused) {
54 scheduler->UnscheduleThread(this, current_priority); 54 scheduler->UnscheduleThread(this, current_priority);
55 } 55 }
56 56
@@ -140,6 +140,11 @@ void Thread::ResumeFromWait() {
140 140
141 wakeup_callback = nullptr; 141 wakeup_callback = nullptr;
142 142
143 if (activity == ThreadActivity::Paused) {
144 status = ThreadStatus::Paused;
145 return;
146 }
147
143 status = ThreadStatus::Ready; 148 status = ThreadStatus::Ready;
144 149
145 ChangeScheduler(); 150 ChangeScheduler();
@@ -391,6 +396,23 @@ bool Thread::InvokeWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> t
391 return wakeup_callback(reason, std::move(thread), std::move(object), index); 396 return wakeup_callback(reason, std::move(thread), std::move(object), index);
392} 397}
393 398
399void Thread::SetActivity(ThreadActivity value) {
400 activity = value;
401
402 if (value == ThreadActivity::Paused) {
403 // Set status if not waiting
404 if (status == ThreadStatus::Ready) {
405 status = ThreadStatus::Paused;
406 } else if (status == ThreadStatus::Running) {
407 status = ThreadStatus::Paused;
408 Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule();
409 }
410 } else if (status == ThreadStatus::Paused) {
411 // Ready to reschedule
412 ResumeFromWait();
413 }
414}
415
394//////////////////////////////////////////////////////////////////////////////////////////////////// 416////////////////////////////////////////////////////////////////////////////////////////////////////
395 417
396/** 418/**