Merge pull request #2396 from Sonicadvance1/fix_racing_cpu_core

Fix a race condition when pausing the CPU core.
This commit is contained in:
Ryan Houdek
2015-05-25 23:06:18 -04:00
6 changed files with 35 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Event.h"
#include "Common/FPURoundMode.h"
#include "Common/MathUtil.h"
@ -33,6 +34,7 @@ static volatile CPUState state = CPU_POWERDOWN;
Interpreter * const interpreter = Interpreter::getInstance();
static CoreMode mode;
static Common::Event s_state_change;
Watches watches;
BreakPoints breakpoints;
@ -238,16 +240,31 @@ void Start()
void Pause()
{
volatile CPUState old_state = state;
state = CPU_STEPPING;
// Wait for the CPU core to leave
if (old_state == CPU_RUNNING)
s_state_change.WaitFor(std::chrono::seconds(1));
Host_UpdateDisasmDialog();
}
void Stop()
{
volatile CPUState old_state = state;
state = CPU_POWERDOWN;
// Wait for the CPU core to leave
if (old_state == CPU_RUNNING)
s_state_change.WaitFor(std::chrono::seconds(1));
Host_UpdateDisasmDialog();
}
void FinishStateMove()
{
s_state_change.Set();
}
void UpdatePerformanceMonitor(u32 cycles, u32 num_load_stores, u32 num_fp_inst)
{
switch (MMCR0.PMC1SELECT)