summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
authorGravatar Morph2022-07-25 12:00:31 -0400
committerGravatar GitHub2022-07-25 12:00:31 -0400
commit591d1f1b09d2af6e432d4fb27af3321919758c0c (patch)
tree5b0efec541b5db56b7d32e6c90f1b2587c71611d /src/core/hle/kernel/kernel.cpp
parentMerge pull request #8484 from german77/irs_release (diff)
parentkernel: Ensure all uses of disable_count are balanced (diff)
downloadyuzu-591d1f1b09d2af6e432d4fb27af3321919758c0c.tar.gz
yuzu-591d1f1b09d2af6e432d4fb27af3321919758c0c.tar.xz
yuzu-591d1f1b09d2af6e432d4fb27af3321919758c0c.zip
Merge pull request #8549 from liamwhite/kscheduler-sc
kernel: use KScheduler from Mesosphere
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r--src/core/hle/kernel/kernel.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index f23c629dc..f4072e1c3 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -64,8 +64,6 @@ struct KernelCore::Impl {
64 64
65 is_phantom_mode_for_singlecore = false; 65 is_phantom_mode_for_singlecore = false;
66 66
67 InitializePhysicalCores();
68
69 // Derive the initial memory layout from the emulated board 67 // Derive the initial memory layout from the emulated board
70 Init::InitializeSlabResourceCounts(kernel); 68 Init::InitializeSlabResourceCounts(kernel);
71 DeriveInitialMemoryLayout(); 69 DeriveInitialMemoryLayout();
@@ -75,9 +73,9 @@ struct KernelCore::Impl {
75 InitializeSystemResourceLimit(kernel, system.CoreTiming()); 73 InitializeSystemResourceLimit(kernel, system.CoreTiming());
76 InitializeMemoryLayout(); 74 InitializeMemoryLayout();
77 Init::InitializeKPageBufferSlabHeap(system); 75 Init::InitializeKPageBufferSlabHeap(system);
78 InitializeSchedulers();
79 InitializeShutdownThreads(); 76 InitializeShutdownThreads();
80 InitializePreemption(kernel); 77 InitializePreemption(kernel);
78 InitializePhysicalCores();
81 79
82 RegisterHostThread(); 80 RegisterHostThread();
83 } 81 }
@@ -136,7 +134,6 @@ struct KernelCore::Impl {
136 shutdown_threads[core_id] = nullptr; 134 shutdown_threads[core_id] = nullptr;
137 } 135 }
138 136
139 schedulers[core_id]->Finalize();
140 schedulers[core_id].reset(); 137 schedulers[core_id].reset();
141 } 138 }
142 139
@@ -199,14 +196,21 @@ struct KernelCore::Impl {
199 exclusive_monitor = 196 exclusive_monitor =
200 Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES); 197 Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES);
201 for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { 198 for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
202 schedulers[i] = std::make_unique<Kernel::KScheduler>(system, i); 199 const s32 core{static_cast<s32>(i)};
200
201 schedulers[i] = std::make_unique<Kernel::KScheduler>(system.Kernel());
203 cores.emplace_back(i, system, *schedulers[i], interrupts); 202 cores.emplace_back(i, system, *schedulers[i], interrupts);
204 }
205 }
206 203
207 void InitializeSchedulers() { 204 auto* main_thread{Kernel::KThread::Create(system.Kernel())};
208 for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { 205 main_thread->SetName(fmt::format("MainThread:{}", core));
209 cores[i].Scheduler().Initialize(); 206 main_thread->SetCurrentCore(core);
207 ASSERT(Kernel::KThread::InitializeMainThread(system, main_thread, core).IsSuccess());
208
209 auto* idle_thread{Kernel::KThread::Create(system.Kernel())};
210 idle_thread->SetCurrentCore(core);
211 ASSERT(Kernel::KThread::InitializeIdleThread(system, idle_thread, core).IsSuccess());
212
213 schedulers[i]->Initialize(main_thread, idle_thread, core);
210 } 214 }
211 } 215 }
212 216
@@ -1109,10 +1113,11 @@ void KernelCore::Suspend(bool suspended) {
1109} 1113}
1110 1114
1111void KernelCore::ShutdownCores() { 1115void KernelCore::ShutdownCores() {
1116 KScopedSchedulerLock lk{*this};
1117
1112 for (auto* thread : impl->shutdown_threads) { 1118 for (auto* thread : impl->shutdown_threads) {
1113 void(thread->Run()); 1119 void(thread->Run());
1114 } 1120 }
1115 InterruptAllPhysicalCores();
1116} 1121}
1117 1122
1118bool KernelCore::IsMulticore() const { 1123bool KernelCore::IsMulticore() const {