summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/scheduler.cpp
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-03-06 14:56:05 -0400
committerGravatar Fernando Sahmkow2020-06-27 11:35:29 -0400
commita33fbaddec5d516328d7cd179114dcf0b93cfb69 (patch)
tree3c4a4ffaae67165e5d4fc380c3f6f899d73f8dac /src/core/hle/kernel/scheduler.cpp
parentScheduler: Release old thread fiber before trying to switch to the next threa... (diff)
downloadyuzu-a33fbaddec5d516328d7cd179114dcf0b93cfb69.tar.gz
yuzu-a33fbaddec5d516328d7cd179114dcf0b93cfb69.tar.xz
yuzu-a33fbaddec5d516328d7cd179114dcf0b93cfb69.zip
Core: Correct rebase.
Diffstat (limited to 'src/core/hle/kernel/scheduler.cpp')
-rw-r--r--src/core/hle/kernel/scheduler.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index aa1f1a305..ae89e908f 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -552,8 +552,7 @@ void GlobalScheduler::Unlock() {
552 EnableInterruptAndSchedule(cores_pending_reschedule, leaving_thread); 552 EnableInterruptAndSchedule(cores_pending_reschedule, leaving_thread);
553} 553}
554 554
555Scheduler::Scheduler(Core::System& system, std::size_t core_id) 555Scheduler::Scheduler(Core::System& system, std::size_t core_id) : system(system), core_id(core_id) {
556 : system(system), core_id(core_id) {
557 switch_fiber = std::make_shared<Common::Fiber>(std::function<void(void*)>(OnSwitch), this); 556 switch_fiber = std::make_shared<Common::Fiber>(std::function<void(void*)>(OnSwitch), this);
558} 557}
559 558
@@ -601,9 +600,10 @@ void Scheduler::SwitchContextStep2() {
601 600
602 // Load context of new thread 601 // Load context of new thread
603 Process* const previous_process = 602 Process* const previous_process =
604 previous_thread != nullptr ? previous_thread->GetOwnerProcess() : nullptr; 603 previous_thread != nullptr ? previous_thread->GetOwnerProcess() : nullptr;
605 604
606 if (new_thread) { 605 if (new_thread) {
606 auto& cpu_core = system.ArmInterface(core_id);
607 new_thread->context_guard.lock(); 607 new_thread->context_guard.lock();
608 cpu_core.Lock(); 608 cpu_core.Lock();
609 ASSERT_MSG(new_thread->GetProcessorID() == s32(this->core_id), 609 ASSERT_MSG(new_thread->GetProcessorID() == s32(this->core_id),
@@ -619,7 +619,6 @@ void Scheduler::SwitchContextStep2() {
619 system.Kernel().MakeCurrentProcess(thread_owner_process); 619 system.Kernel().MakeCurrentProcess(thread_owner_process);
620 } 620 }
621 if (!new_thread->IsHLEThread()) { 621 if (!new_thread->IsHLEThread()) {
622 auto& cpu_core = system.ArmInterface(core_id);
623 cpu_core.LoadContext(new_thread->GetContext32()); 622 cpu_core.LoadContext(new_thread->GetContext32());
624 cpu_core.LoadContext(new_thread->GetContext64()); 623 cpu_core.LoadContext(new_thread->GetContext64());
625 cpu_core.SetTlsAddress(new_thread->GetTLSAddress()); 624 cpu_core.SetTlsAddress(new_thread->GetTLSAddress());
@@ -651,12 +650,12 @@ void Scheduler::SwitchContext() {
651 650
652 // Save context for previous thread 651 // Save context for previous thread
653 if (previous_thread) { 652 if (previous_thread) {
653 auto& cpu_core = system.ArmInterface(core_id);
654 if (!previous_thread->IsHLEThread()) { 654 if (!previous_thread->IsHLEThread()) {
655 auto& cpu_core = system.ArmInterface(core_id);
656 cpu_core.SaveContext(previous_thread->GetContext32()); 655 cpu_core.SaveContext(previous_thread->GetContext32());
657 cpu_core.SaveContext(previous_thread->GetContext64()); 656 cpu_core.SaveContext(previous_thread->GetContext64());
658 // Save the TPIDR_EL0 system register in case it was modified. 657 // Save the TPIDR_EL0 system register in case it was modified.
659 previous_thread->SetTPIDR_EL0(cpu_core.GetTPIDR_EL0()); 658 previous_thread->SetTPIDR_EL0(cpu_core.GetTPIDR_EL0());
660 cpu_core.ClearExclusiveState(); 659 cpu_core.ClearExclusiveState();
661 } 660 }
662 if (previous_thread->GetStatus() == ThreadStatus::Running) { 661 if (previous_thread->GetStatus() == ThreadStatus::Running) {