diff options
| author | Silent <zdanio95@gmail.com> | 2019-08-25 18:00:43 +0200 |
|---|---|---|
| committer | Silent <zdanio95@gmail.com> | 2019-11-22 22:07:41 +0100 |
| commit | e30ff7c327ff64d3a226476a0fd7165abc6e7937 (patch) | |
| tree | fe485a8b8e7965f4a6d2708e838edbca8dad75b9 /Source/Core | |
| parent | 28f7c5fb2a5bde83ac86eacc06058ea0bac8d82e (diff) | |
DSPLLE: Put DSP thread in idle state if it's paused to prevent a deadlock
DSP thread is considered "idle" when it signals s_ppc_event and waits for s_dsp_event,
without putting it in this state when m_dsp_thread_mutex is locked it was possible to
create a deadlock between a DSP thread, emulation thread and Qt thread by accessing
Config menu immediately after booting up the game
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/HW/DSPLLE/DSPLLE.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp index 6f27f485fc..dc0f463fba 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp @@ -98,22 +98,24 @@ void DSPLLE::DSPThread(DSPLLE* dsp_lle) const int cycles = static_cast<int>(dsp_lle->m_cycle_count.load()); if (cycles > 0) { - std::lock_guard<std::mutex> dsp_thread_lock(dsp_lle->m_dsp_thread_mutex); - if (g_dsp_jit) + std::unique_lock dsp_thread_lock(dsp_lle->m_dsp_thread_mutex, std::try_to_lock); + if (dsp_thread_lock) { - DSPCore_RunCycles(cycles); + if (g_dsp_jit) + { + DSPCore_RunCycles(cycles); + } + else + { + DSP::Interpreter::RunCyclesThread(cycles); + } + dsp_lle->m_cycle_count.store(0); + continue; } - else - { - DSP::Interpreter::RunCyclesThread(cycles); - } - dsp_lle->m_cycle_count.store(0); - } - else - { - s_ppc_event.Set(); - s_dsp_event.Wait(); } + + s_ppc_event.Set(); + s_dsp_event.Wait(); } } |
