yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0
This repository has been archived on 2024-03-23. You can view files and clone it, but cannot push or open issues or pull requests.
yuzu-mainline/src/core/core_cpu.h

79 lines
1.4 KiB
C
Raw Normal View History

// Copyright 2018 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <atomic>
#include <condition_variable>
#include <memory>
#include <mutex>
#include <string>
#include "common/common_types.h"
class ARM_Interface;
namespace Kernel {
class Scheduler;
}
namespace Core {
constexpr unsigned NUM_CPU_CORES{4};
class CpuBarrier {
public:
bool IsAlive() const {
return !end;
}
void NotifyEnd();
bool Rendezvous();
private:
unsigned cores_waiting{NUM_CPU_CORES};
std::mutex mutex;
std::condition_variable condition;
std::atomic<bool> end{};
};
class Cpu {
public:
Cpu(std::shared_ptr<CpuBarrier> cpu_barrier, size_t core_index);
void RunLoop(bool tight_loop = true);
void SingleStep();
void PrepareReschedule();
2018-05-03 02:36:51 +00:00
ARM_Interface& ArmInterface() {
return *arm_interface;
}
2018-05-03 02:36:51 +00:00
const ARM_Interface& ArmInterface() const {
return *arm_interface;
}
const std::shared_ptr<Kernel::Scheduler>& Scheduler() const {
return scheduler;
}
bool IsMainCore() const {
return core_index == 0;
}
private:
void Reschedule();
std::shared_ptr<ARM_Interface> arm_interface;
std::shared_ptr<CpuBarrier> cpu_barrier;
2018-05-03 02:36:51 +00:00
std::shared_ptr<Kernel::Scheduler> scheduler;
bool reschedule_pending{};
size_t core_index;
};
} // namespace Core