Skip to content
Snippets Groups Projects

Debugging changes

Merged Florian Fischer requested to merge emper_debug into master
4 files
+ 50
30
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -7,6 +7,7 @@
@@ -7,6 +7,7 @@
#include "Common.hpp" // for unlikely
#include "Common.hpp" // for unlikely
#include "Context.hpp" // for Context
#include "Context.hpp" // for Context
#include "Debug.hpp" // for LOGDD
#include "Debug.hpp" // for LOGDD
 
#include "Emper.hpp" // for emper::DEBUG
void BinaryPrivateSemaphore::wait() {
void BinaryPrivateSemaphore::wait() {
State state = bpsState.load();
State state = bpsState.load();
@@ -28,13 +29,13 @@ void BinaryPrivateSemaphore::wait() {
@@ -28,13 +29,13 @@ void BinaryPrivateSemaphore::wait() {
State newState = blocked;
State newState = blocked;
State previousState = bpsState.exchange(newState);
State previousState = bpsState.exchange(newState);
if (previousState == signaled) {
if (previousState == signaled) {
#ifndef NDEBUG
if constexpr (emper::DEBUG) {
// Reset the real signal state only in debug
// Reset the real signal state only in debug
// builds. As it is not required to set the state here
// builds. As it is not required to set the state here
// for the correctnes of the synchronization primitive.
// for the correctnes of the synchronization primitive.
newState = signaled;
newState = signaled;
bpsState.store(newState, std::memory_order_relaxed);
bpsState.store(newState, std::memory_order_relaxed);
#endif
}
unblock(blockedContext);
unblock(blockedContext);
}
}
});
});
@@ -48,13 +49,13 @@ auto BinaryPrivateSemaphore::signalInternal() -> Context* {
@@ -48,13 +49,13 @@ auto BinaryPrivateSemaphore::signalInternal() -> Context* {
if (currentState != initial) {
if (currentState != initial) {
// Fast path: If the state is not initial then someone is
// Fast path: If the state is not initial then someone is
// waiting, because the state can't be signaled.
// waiting, because the state can't be signaled.
#ifndef NDEBUG
if constexpr (emper::DEBUG) {
State newState = signaled;
State newState = signaled;
// Reset the real signal state only in debug
// Reset the real signal state only in debug
// builds. As it is not required to set the state here
// builds. As it is not required to set the state here
// for the correctnes of the synchronization primitive.
// for the correctnes of the synchronization primitive.
bpsState.store(newState);
bpsState.store(newState);
#endif
}
LOGDD("unblock in fast path");
LOGDD("unblock in fast path");
return blockedContext;
return blockedContext;
}
}
Loading