diff options
| author | 2020-03-03 15:50:38 -0400 | |
|---|---|---|
| committer | 2020-06-27 11:35:23 -0400 | |
| commit | 07993ac8c8c66bbf638dddc7750106f6dfb0e09b (patch) | |
| tree | dae8c8249f66657e232dc2620489d237e17459c8 /src/core/hle/kernel/scheduler.cpp | |
| parent | Kernel: Correct Signal on Thread Death and Setup Sync Objects on Thread for D... (diff) | |
| download | yuzu-07993ac8c8c66bbf638dddc7750106f6dfb0e09b.tar.gz yuzu-07993ac8c8c66bbf638dddc7750106f6dfb0e09b.tar.xz yuzu-07993ac8c8c66bbf638dddc7750106f6dfb0e09b.zip | |
Kernel: Corrections to Scheduling.
Diffstat (limited to 'src/core/hle/kernel/scheduler.cpp')
| -rw-r--r-- | src/core/hle/kernel/scheduler.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index d67d3c5cd..da77967dd 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp | |||
| @@ -47,13 +47,13 @@ u32 GlobalScheduler::SelectThreads() { | |||
| 47 | ASSERT(is_locked); | 47 | ASSERT(is_locked); |
| 48 | const auto update_thread = [](Thread* thread, Scheduler& sched) { | 48 | const auto update_thread = [](Thread* thread, Scheduler& sched) { |
| 49 | sched.guard.lock(); | 49 | sched.guard.lock(); |
| 50 | if (thread != sched.selected_thread.get()) { | 50 | if (thread != sched.selected_thread_set.get()) { |
| 51 | if (thread == nullptr) { | 51 | if (thread == nullptr) { |
| 52 | ++sched.idle_selection_count; | 52 | ++sched.idle_selection_count; |
| 53 | } | 53 | } |
| 54 | sched.selected_thread = SharedFrom(thread); | 54 | sched.selected_thread_set = SharedFrom(thread); |
| 55 | } | 55 | } |
| 56 | const bool reschedule_pending = sched.selected_thread != sched.current_thread; | 56 | const bool reschedule_pending = sched.selected_thread_set != sched.current_thread; |
| 57 | sched.is_context_switch_pending = reschedule_pending; | 57 | sched.is_context_switch_pending = reschedule_pending; |
| 58 | std::atomic_thread_fence(std::memory_order_seq_cst); | 58 | std::atomic_thread_fence(std::memory_order_seq_cst); |
| 59 | sched.guard.unlock(); | 59 | sched.guard.unlock(); |
| @@ -118,6 +118,8 @@ u32 GlobalScheduler::SelectThreads() { | |||
| 118 | suggested); | 118 | suggested); |
| 119 | top_threads[candidate_core] = next; | 119 | top_threads[candidate_core] = next; |
| 120 | break; | 120 | break; |
| 121 | } else { | ||
| 122 | suggested = nullptr; | ||
| 121 | } | 123 | } |
| 122 | } | 124 | } |
| 123 | } | 125 | } |
| @@ -590,7 +592,7 @@ void Scheduler::OnThreadStart() { | |||
| 590 | } | 592 | } |
| 591 | 593 | ||
| 592 | void Scheduler::SwitchContextStep2() { | 594 | void Scheduler::SwitchContextStep2() { |
| 593 | Thread* previous_thread = current_thread.get(); | 595 | Thread* previous_thread = current_thread_prev.get(); |
| 594 | Thread* new_thread = selected_thread.get(); | 596 | Thread* new_thread = selected_thread.get(); |
| 595 | 597 | ||
| 596 | // Load context of new thread | 598 | // Load context of new thread |
| @@ -606,8 +608,6 @@ void Scheduler::SwitchContextStep2() { | |||
| 606 | "Thread must be ready to become running."); | 608 | "Thread must be ready to become running."); |
| 607 | 609 | ||
| 608 | // Cancel any outstanding wakeup events for this thread | 610 | // Cancel any outstanding wakeup events for this thread |
| 609 | current_thread = SharedFrom(new_thread); | ||
| 610 | new_thread->SetStatus(ThreadStatus::Running); | ||
| 611 | new_thread->SetIsRunning(true); | 611 | new_thread->SetIsRunning(true); |
| 612 | 612 | ||
| 613 | auto* const thread_owner_process = current_thread->GetOwnerProcess(); | 613 | auto* const thread_owner_process = current_thread->GetOwnerProcess(); |
| @@ -622,21 +622,21 @@ void Scheduler::SwitchContextStep2() { | |||
| 622 | cpu_core.SetTPIDR_EL0(new_thread->GetTPIDR_EL0()); | 622 | cpu_core.SetTPIDR_EL0(new_thread->GetTPIDR_EL0()); |
| 623 | cpu_core.ClearExclusiveState(); | 623 | cpu_core.ClearExclusiveState(); |
| 624 | } | 624 | } |
| 625 | } else { | ||
| 626 | current_thread = nullptr; | ||
| 627 | // Note: We do not reset the current process and current page table when idling because | ||
| 628 | // technically we haven't changed processes, our threads are just paused. | ||
| 629 | } | 625 | } |
| 630 | guard.unlock(); | 626 | |
| 627 | TryDoContextSwitch(); | ||
| 631 | } | 628 | } |
| 632 | 629 | ||
| 633 | void Scheduler::SwitchContext() { | 630 | void Scheduler::SwitchContext() { |
| 634 | Thread* previous_thread = current_thread.get(); | 631 | current_thread_prev = current_thread; |
| 632 | selected_thread = selected_thread_set; | ||
| 633 | Thread* previous_thread = current_thread_prev.get(); | ||
| 635 | Thread* new_thread = selected_thread.get(); | 634 | Thread* new_thread = selected_thread.get(); |
| 635 | current_thread = selected_thread; | ||
| 636 | 636 | ||
| 637 | is_context_switch_pending = false; | 637 | is_context_switch_pending = false; |
| 638 | guard.unlock(); | ||
| 638 | if (new_thread == previous_thread) { | 639 | if (new_thread == previous_thread) { |
| 639 | guard.unlock(); | ||
| 640 | return; | 640 | return; |
| 641 | } | 641 | } |
| 642 | 642 | ||