diff options
Diffstat (limited to 'Transceiver52M')
-rw-r--r-- | Transceiver52M/osmo-trx.cpp | 5 | ||||
-rw-r--r-- | Transceiver52M/radioInterface.cpp | 11 | ||||
-rw-r--r-- | Transceiver52M/radioInterface.h | 2 | ||||
-rw-r--r-- | Transceiver52M/radioInterfaceMulti.cpp | 4 | ||||
-rw-r--r-- | Transceiver52M/radioInterfaceResamp.cpp | 4 |
5 files changed, 16 insertions, 10 deletions
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp index ab0b631..9fe6585 100644 --- a/Transceiver52M/osmo-trx.cpp +++ b/Transceiver52M/osmo-trx.cpp @@ -571,6 +571,11 @@ int main(int argc, char *argv[]) #endif #endif +#ifndef HAVE_ATOMIC_OPS +#pragma message ("Built without atomic operation support. Using Mutex, it may affect performance!") + printf("Built without atomic operation support. Using Mutex, it may affect performance!\n"); +#endif + if (!log_mutex_init()) { fprintf(stderr, "Failed to initialize log mutex!\n"); exit(2); diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp index 6e49a75..fbcacf1 100644 --- a/Transceiver52M/radioInterface.cpp +++ b/Transceiver52M/radioInterface.cpp @@ -24,6 +24,7 @@ #include "radioInterface.h" #include "Resampler.h" #include <Logger.h> +#include <Threads.h> extern "C" { #include "convert.h" @@ -288,9 +289,9 @@ int RadioInterface::driveReceiveRadio() bool RadioInterface::isUnderrun() { - bool retVal = underrun; - underrun = false; - + bool retVal; + /* atomically get previous value of "underrun" and set the var to false */ + retVal = osmo_trx_sync_fetch_and_and(&underrun, false); return retVal; } @@ -340,7 +341,7 @@ int RadioInterface::pullBuffer() segmentLen * 2); } - underrun |= local_underrun; + osmo_trx_sync_or_and_fetch(&underrun, local_underrun); readTimestamp += numRecv; return 0; } @@ -366,7 +367,7 @@ bool RadioInterface::pushBuffer() segmentLen, &local_underrun, writeTimestamp); - underrun |= local_underrun; + osmo_trx_sync_or_and_fetch(&underrun, local_underrun); writeTimestamp += numSent; return true; diff --git a/Transceiver52M/radioInterface.h b/Transceiver52M/radioInterface.h index b12c187..d72fb69 100644 --- a/Transceiver52M/radioInterface.h +++ b/Transceiver52M/radioInterface.h @@ -48,7 +48,7 @@ protected: std::vector<short *> convertRecvBuffer; std::vector<short *> convertSendBuffer; std::vector<float> powerScaling; - bool underrun; ///< indicates writes to USRP are too slow + int underrun; ///< indicates writes to USRP are too slow bool overrun; ///< indicates reads from USRP are too slow TIMESTAMP writeTimestamp; ///< sample timestamp of next packet written to USRP TIMESTAMP readTimestamp; ///< sample timestamp of next packet read from USRP diff --git a/Transceiver52M/radioInterfaceMulti.cpp b/Transceiver52M/radioInterfaceMulti.cpp index eec426e..92e31e1 100644 --- a/Transceiver52M/radioInterfaceMulti.cpp +++ b/Transceiver52M/radioInterfaceMulti.cpp @@ -251,7 +251,7 @@ int RadioInterfaceMulti::pullBuffer() convert_short_float((float *) outerRecvBuffer->begin(), convertRecvBuffer[0], 2 * outerRecvBuffer->size()); - underrun |= local_underrun; + osmo_trx_sync_or_and_fetch(&underrun, local_underrun); readTimestamp += num; channelizer->rotate((float *) outerRecvBuffer->begin(), @@ -348,7 +348,7 @@ bool RadioInterfaceMulti::pushBuffer() LOG(ALERT) << "Transmit error " << num; } - underrun |= local_underrun; + osmo_trx_sync_or_and_fetch(&underrun, local_underrun); writeTimestamp += num; return true; diff --git a/Transceiver52M/radioInterfaceResamp.cpp b/Transceiver52M/radioInterfaceResamp.cpp index 864cdee..b92432f 100644 --- a/Transceiver52M/radioInterfaceResamp.cpp +++ b/Transceiver52M/radioInterfaceResamp.cpp @@ -184,7 +184,7 @@ int RadioInterfaceResamp::pullBuffer() convert_short_float((float *) outerRecvBuffer->begin(), convertRecvBuffer[0], 2 * resamp_outchunk); - underrun |= local_underrun; + osmo_trx_sync_or_and_fetch(&underrun, local_underrun); readTimestamp += (TIMESTAMP) resamp_outchunk; /* Write to the end of the inner receive buffer */ @@ -232,7 +232,7 @@ bool RadioInterfaceResamp::pushBuffer() LOG(ALERT) << "Transmit error " << numSent; } - underrun |= local_underrun; + osmo_trx_sync_or_and_fetch(&underrun, local_underrun); writeTimestamp += resamp_outchunk; return true; |