diff options
Diffstat (limited to 'src/core/cpu_manager.cpp')
| -rw-r--r-- | src/core/cpu_manager.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index 2e9dc9dc3..604405060 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp | |||
| @@ -232,13 +232,10 @@ void CpuManager::SingleCoreRunGuestLoop() { | |||
| 232 | auto* physical_core = &kernel.CurrentPhysicalCore(); | 232 | auto* physical_core = &kernel.CurrentPhysicalCore(); |
| 233 | auto& arm_interface = thread->ArmInterface(); | 233 | auto& arm_interface = thread->ArmInterface(); |
| 234 | system.EnterDynarmicProfile(); | 234 | system.EnterDynarmicProfile(); |
| 235 | while (!physical_core->IsInterrupted()) { | 235 | if (!physical_core->IsInterrupted()) { |
| 236 | system.CoreTiming().ResetTicks(); | ||
| 236 | arm_interface.Run(); | 237 | arm_interface.Run(); |
| 237 | physical_core = &kernel.CurrentPhysicalCore(); | 238 | physical_core = &kernel.CurrentPhysicalCore(); |
| 238 | preemption_count++; | ||
| 239 | if (preemption_count % max_cycle_runs == 0) { | ||
| 240 | break; | ||
| 241 | } | ||
| 242 | } | 239 | } |
| 243 | system.ExitDynarmicProfile(); | 240 | system.ExitDynarmicProfile(); |
| 244 | thread->SetPhantomMode(true); | 241 | thread->SetPhantomMode(true); |
| @@ -255,7 +252,7 @@ void CpuManager::SingleCoreRunIdleThread() { | |||
| 255 | auto& kernel = system.Kernel(); | 252 | auto& kernel = system.Kernel(); |
| 256 | while (true) { | 253 | while (true) { |
| 257 | auto& physical_core = kernel.CurrentPhysicalCore(); | 254 | auto& physical_core = kernel.CurrentPhysicalCore(); |
| 258 | PreemptSingleCore(); | 255 | PreemptSingleCore(false); |
| 259 | idle_count++; | 256 | idle_count++; |
| 260 | auto& scheduler = physical_core.Scheduler(); | 257 | auto& scheduler = physical_core.Scheduler(); |
| 261 | scheduler.TryDoContextSwitch(); | 258 | scheduler.TryDoContextSwitch(); |
| @@ -279,12 +276,15 @@ void CpuManager::SingleCoreRunSuspendThread() { | |||
| 279 | } | 276 | } |
| 280 | } | 277 | } |
| 281 | 278 | ||
| 282 | void CpuManager::PreemptSingleCore() { | 279 | void CpuManager::PreemptSingleCore(bool from_running_enviroment) { |
| 283 | preemption_count = 0; | ||
| 284 | std::size_t old_core = current_core; | 280 | std::size_t old_core = current_core; |
| 285 | auto& scheduler = system.Kernel().Scheduler(old_core); | 281 | auto& scheduler = system.Kernel().Scheduler(old_core); |
| 286 | Kernel::Thread* current_thread = scheduler.GetCurrentThread(); | 282 | Kernel::Thread* current_thread = scheduler.GetCurrentThread(); |
| 287 | if (idle_count >= 4) { | 283 | if (idle_count >= 4 || from_running_enviroment) { |
| 284 | if (!from_running_enviroment) { | ||
| 285 | system.CoreTiming().Idle(); | ||
| 286 | idle_count = 0; | ||
| 287 | } | ||
| 288 | current_thread->SetPhantomMode(true); | 288 | current_thread->SetPhantomMode(true); |
| 289 | system.CoreTiming().Advance(); | 289 | system.CoreTiming().Advance(); |
| 290 | current_thread->SetPhantomMode(false); | 290 | current_thread->SetPhantomMode(false); |