diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2022-07-25 18:00:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 18:00:31 +0200 |
commit | 591d1f1b09d2af6e432d4fb27af3321919758c0c (patch) | |
tree | 5b0efec541b5db56b7d32e6c90f1b2587c71611d /src/core/hle/kernel/kernel.cpp | |
parent | Merge pull request #8484 from german77/irs_release (diff) | |
parent | kernel: Ensure all uses of disable_count are balanced (diff) | |
download | yuzu-591d1f1b09d2af6e432d4fb27af3321919758c0c.tar yuzu-591d1f1b09d2af6e432d4fb27af3321919758c0c.tar.gz yuzu-591d1f1b09d2af6e432d4fb27af3321919758c0c.tar.bz2 yuzu-591d1f1b09d2af6e432d4fb27af3321919758c0c.tar.lz yuzu-591d1f1b09d2af6e432d4fb27af3321919758c0c.tar.xz yuzu-591d1f1b09d2af6e432d4fb27af3321919758c0c.tar.zst yuzu-591d1f1b09d2af6e432d4fb27af3321919758c0c.zip |
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r-- | src/core/hle/kernel/kernel.cpp | 27 |
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 { is_phantom_mode_for_singlecore = false; - InitializePhysicalCores(); - // Derive the initial memory layout from the emulated board Init::InitializeSlabResourceCounts(kernel); DeriveInitialMemoryLayout(); @@ -75,9 +73,9 @@ struct KernelCore::Impl { InitializeSystemResourceLimit(kernel, system.CoreTiming()); InitializeMemoryLayout(); Init::InitializeKPageBufferSlabHeap(system); - InitializeSchedulers(); InitializeShutdownThreads(); InitializePreemption(kernel); + InitializePhysicalCores(); RegisterHostThread(); } @@ -136,7 +134,6 @@ struct KernelCore::Impl { shutdown_threads[core_id] = nullptr; } - schedulers[core_id]->Finalize(); schedulers[core_id].reset(); } @@ -199,14 +196,21 @@ struct KernelCore::Impl { exclusive_monitor = Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES); for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { - schedulers[i] = std::make_unique<Kernel::KScheduler>(system, i); + const s32 core{static_cast<s32>(i)}; + + schedulers[i] = std::make_unique<Kernel::KScheduler>(system.Kernel()); cores.emplace_back(i, system, *schedulers[i], interrupts); - } - } - void InitializeSchedulers() { - for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { - cores[i].Scheduler().Initialize(); + auto* main_thread{Kernel::KThread::Create(system.Kernel())}; + main_thread->SetName(fmt::format("MainThread:{}", core)); + main_thread->SetCurrentCore(core); + ASSERT(Kernel::KThread::InitializeMainThread(system, main_thread, core).IsSuccess()); + + auto* idle_thread{Kernel::KThread::Create(system.Kernel())}; + idle_thread->SetCurrentCore(core); + ASSERT(Kernel::KThread::InitializeIdleThread(system, idle_thread, core).IsSuccess()); + + schedulers[i]->Initialize(main_thread, idle_thread, core); } } @@ -1109,10 +1113,11 @@ void KernelCore::Suspend(bool suspended) { } void KernelCore::ShutdownCores() { + KScopedSchedulerLock lk{*this}; + for (auto* thread : impl->shutdown_threads) { void(thread->Run()); } - InterruptAllPhysicalCores(); } bool KernelCore::IsMulticore() const { |