commit 2e5046656afe338b03b74fc521238da3fb26c266
parent 0a26bbb56c009b48f89a25ddf848d897e61a765c
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Mon, 27 Jan 2025 00:33:53 +0100
fix possible race condition in UC/DSP synchronization
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/source/hardwareLib/haltDSP.h b/source/hardwareLib/haltDSP.h
@@ -3,8 +3,9 @@
#include <cstdint>
#include <functional>
#include <unordered_map>
+#include <atomic>
-#include "baseLib/semaphore.h"
+#include "dsp56kEmu/semaphore.h"
namespace dsp56k
{
@@ -35,12 +36,12 @@ namespace hwLib
uint32_t m_halted = 0;
uint32_t m_irq;
- baseLib::Semaphore m_blockSem;
+ dsp56k::SpscSemaphore m_blockSem;
std::mutex m_mutex;
std::condition_variable m_cvHalted;
- uint32_t m_irqServedCount = 0;
+ std::atomic<uint32_t> m_irqServedCount = 0;
uint32_t m_irqRequestCount = 0;
uint32_t m_wakeUpId = 0;
@@ -48,7 +49,7 @@ namespace hwLib
std::unordered_map<uint32_t, std::function<void()>> m_wakeUps;
- bool m_halting = false;
+ std::atomic<bool> m_halting = false;
};
class ScopedResumeDSP