diff options
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 4ffb76818..748c45dd7 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(); |
| @@ -388,6 +393,23 @@ bool Thread::InvokeWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> t | |||
| 388 | return wakeup_callback(reason, std::move(thread), std::move(object), index); | 393 | return wakeup_callback(reason, std::move(thread), std::move(object), index); |
| 389 | } | 394 | } |
| 390 | 395 | ||
| 396 | void Thread::SetActivity(ThreadActivity value) { | ||
| 397 | activity = value; | ||
| 398 | |||
| 399 | if (value == ThreadActivity::Paused) { | ||
| 400 | // Set status if not waiting | ||
| 401 | if (status == ThreadStatus::Ready) { | ||
| 402 | status = ThreadStatus::Paused; | ||
| 403 | } else if (status == ThreadStatus::Running) { | ||
| 404 | status = ThreadStatus::Paused; | ||
| 405 | Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); | ||
| 406 | } | ||
| 407 | } else if (status == ThreadStatus::Paused) { | ||
| 408 | // Ready to reschedule | ||
| 409 | ResumeFromWait(); | ||
| 410 | } | ||
| 411 | } | ||
| 412 | |||
| 391 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 413 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 392 | 414 | ||
| 393 | /** | 415 | /** |