System: Address Feedback

This commit is contained in:
Fernando Sahmkow 2020-01-26 16:14:18 -04:00 committed by FernandoS27
parent de4b01f75d
commit 2d1984c20c
11 changed files with 30 additions and 24 deletions

View file

@ -135,7 +135,8 @@ struct KernelCore::Impl {
}
void InitializePhysicalCores(KernelCore& kernel) {
exclusive_monitor = Core::MakeExclusiveMonitor(system.Memory(), global_scheduler.CpuCoresCount());
exclusive_monitor =
Core::MakeExclusiveMonitor(system.Memory(), global_scheduler.CpuCoresCount());
for (std::size_t i = 0; i < global_scheduler.CpuCoresCount(); i++) {
cores.emplace_back(system, kernel, i, *exclusive_monitor);
}
@ -284,7 +285,7 @@ void KernelCore::InvalidateAllInstructionCaches() {
}
void KernelCore::PrepareReschedule(std::size_t id) {
if (id >= 0 && id < impl->global_scheduler.CpuCoresCount()) {
if (id < impl->global_scheduler.CpuCoresCount()) {
impl->cores[id].Stop();
}
}

View file

@ -13,7 +13,7 @@
namespace Core {
class ExclusiveMonitor;
class System;
}
} // namespace Core
namespace Core::Timing {
class CoreTiming;

View file

@ -17,18 +17,21 @@
namespace Kernel {
PhysicalCore::PhysicalCore(Core::System& system, KernelCore& kernel, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor)
PhysicalCore::PhysicalCore(Core::System& system, KernelCore& kernel, std::size_t id,
Core::ExclusiveMonitor& exclusive_monitor)
: core_index{id}, kernel{kernel} {
#ifdef ARCHITECTURE_x86_64
arm_interface = std::make_unique<Core::ARM_Dynarmic>(system, exclusive_monitor, core_index);
arm_interface = std::make_shared<Core::ARM_Dynarmic>(system, exclusive_monitor, core_index);
#else
arm_interface = std::make_unique<Core::ARM_Unicorn>(system);
arm_interface = std::make_shared<Core::ARM_Unicorn>(system);
LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available");
#endif
scheduler = std::make_unique<Kernel::Scheduler>(system, *arm_interface, core_index);
scheduler = std::make_shared<Kernel::Scheduler>(system, *arm_interface, core_index);
}
PhysicalCore::~PhysicalCore() = default;
void PhysicalCore::Run() {
arm_interface->Run();
arm_interface->ClearExclusiveState();

View file

@ -4,6 +4,9 @@
#pragma once
#include <cstddef>
#include <memory>
namespace Kernel {
class Scheduler;
} // namespace Kernel
@ -18,7 +21,10 @@ namespace Kernel {
class PhysicalCore {
public:
PhysicalCore(Core::System& system, KernelCore& kernel, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor);
PhysicalCore(Core::System& system, KernelCore& kernel, std::size_t id,
Core::ExclusiveMonitor& exclusive_monitor);
~PhysicalCore();
/// Execute current jit state
void Run();
@ -61,8 +67,8 @@ public:
private:
std::size_t core_index;
KernelCore& kernel;
std::unique_ptr<Core::ARM_Interface> arm_interface;
std::unique_ptr<Kernel::Scheduler> scheduler;
std::shared_ptr<Core::ARM_Interface> arm_interface;
std::shared_ptr<Kernel::Scheduler> scheduler;
};
} // namespace Kernel