diff options
| author | 2018-12-26 15:54:14 -0500 | |
|---|---|---|
| committer | 2018-12-26 15:54:14 -0500 | |
| commit | ae582b6669eed99e66829b1941152f0b8b073128 (patch) | |
| tree | 5aa768c110f6876823a61d31193cca58c103ddc6 /src/core/hle/kernel/thread.cpp | |
| parent | Merge pull request #1943 from ReinUsesLisp/fixup-texs (diff) | |
| parent | debugger: Set paused thread color (diff) | |
| download | yuzu-ae582b6669eed99e66829b1941152f0b8b073128.tar.gz yuzu-ae582b6669eed99e66829b1941152f0b8b073128.tar.xz yuzu-ae582b6669eed99e66829b1941152f0b8b073128.zip | |
Merge pull request #1849 from encounter/svcSetThreadActivity
svc: Implement SetThreadActivity (thread suspension)
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 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 | ||
| 399 | void 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 | /** |