summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-08-07 08:12:47 +0200
committerbunnei <bunneidev@gmail.com>2021-12-07 01:39:16 +0100
commitf412d2027a6e5798fe6fc3b43250bc2f5f1d17fc (patch)
tree129eaee0437556121f8b5e986345b83cf7c4af24 /src/core
parentcore: hle: kernel: k_process: DisableDispatch on main thread. (diff)
downloadyuzu-f412d2027a6e5798fe6fc3b43250bc2f5f1d17fc.tar
yuzu-f412d2027a6e5798fe6fc3b43250bc2f5f1d17fc.tar.gz
yuzu-f412d2027a6e5798fe6fc3b43250bc2f5f1d17fc.tar.bz2
yuzu-f412d2027a6e5798fe6fc3b43250bc2f5f1d17fc.tar.lz
yuzu-f412d2027a6e5798fe6fc3b43250bc2f5f1d17fc.tar.xz
yuzu-f412d2027a6e5798fe6fc3b43250bc2f5f1d17fc.tar.zst
yuzu-f412d2027a6e5798fe6fc3b43250bc2f5f1d17fc.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/kernel/k_scheduler.cpp46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp
index 4bae69f71..5ee4b8adc 100644
--- a/src/core/hle/kernel/k_scheduler.cpp
+++ b/src/core/hle/kernel/k_scheduler.cpp
@@ -650,6 +650,7 @@ void KScheduler::RescheduleCurrentCore() {
if (state.needs_scheduling.load()) {
Schedule();
} else {
+ GetCurrentThread()->EnableDispatch();
guard.Unlock();
}
}
@@ -659,26 +660,37 @@ void KScheduler::OnThreadStart() {
}
void KScheduler::Unload(KThread* thread) {
+ ASSERT(thread);
+
+ if (!thread) {
+ return;
+ }
+
LOG_TRACE(Kernel, "core {}, unload thread {}", core_id, thread ? thread->GetName() : "nullptr");
- if (thread) {
- if (thread->IsCallingSvc()) {
- thread->ClearIsCallingSvc();
- }
- if (!thread->IsTerminationRequested()) {
- prev_thread = thread;
-
- Core::ARM_Interface& cpu_core = system.ArmInterface(core_id);
- cpu_core.SaveContext(thread->GetContext32());
- cpu_core.SaveContext(thread->GetContext64());
- // Save the TPIDR_EL0 system register in case it was modified.
- thread->SetTPIDR_EL0(cpu_core.GetTPIDR_EL0());
- cpu_core.ClearExclusiveState();
- } else {
- prev_thread = nullptr;
- }
- thread->context_guard.Unlock();
+ if (thread->IsCallingSvc()) {
+ thread->ClearIsCallingSvc();
}
+
+ auto& physical_core = system.Kernel().PhysicalCore(core_id);
+ if (!physical_core.IsInitialized()) {
+ return;
+ }
+
+ Core::ARM_Interface& cpu_core = physical_core.ArmInterface();
+ cpu_core.SaveContext(thread->GetContext32());
+ cpu_core.SaveContext(thread->GetContext64());
+ // Save the TPIDR_EL0 system register in case it was modified.
+ thread->SetTPIDR_EL0(cpu_core.GetTPIDR_EL0());
+ cpu_core.ClearExclusiveState();
+
+ if (!thread->IsTerminationRequested() && thread->GetActiveCore() == core_id) {
+ prev_thread = thread;
+ } else {
+ prev_thread = nullptr;
+ }
+
+ thread->context_guard.Unlock();
}
void KScheduler::Reload(KThread* thread) {