diff options
author | Thomas Tsou <ttsou@vt.edu> | 2012-03-17 15:02:32 -0400 |
---|---|---|
committer | Alexander Chemeris <Alexander.Chemeris@gmail.com> | 2013-06-24 01:51:02 +0400 |
commit | 5f13377b83bc5bfafaf6b150a4b507f190cee585 (patch) | |
tree | 9e64451a2bd9c399e62dc9da45f32cce571d6fc3 /Transceiver52M/Transceiver.h | |
parent | a6ca73ca67b2a66f46be4bafd5ebf397a3c0a2af (diff) |
multi-arfcn, trx: handle thread exiting on shutdown
Previous approach was to allow stack unwinding to take care
shutdown and thread ending, which was unpredictable and
occasionally segfault. Attempt to shutdown more gracefully.
There are thread cancellation points in the transceiver code
using pthread_testcancel(), but the thread abstraction library
does not allow direct access to the pthread variables. This
prevents thread shutdown through pthread_cancel(). To get
around this, use boolean status values in the receive socket
service loops and main drive loop.
The socket read calls will block indefinitly, so shutdown
may cause the socket implementation to throw a SocketError
exception. Use of timeout values with reads does not seem to
work correctly or reliably, so catch the exception and ignore
if it occurs on shutdown.
The following error may appear as the socket is shutdown while
the Transceiver is blocking on read().
DatagramSocket::read() failed: Bad file descriptor
So be it; the API doesn't allow us to do any more.
Signed-off-by: Thomas Tsou <ttsou@vt.edu>
Diffstat (limited to 'Transceiver52M/Transceiver.h')
-rw-r--r-- | Transceiver52M/Transceiver.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h index fed2df9..1b4e181 100644 --- a/Transceiver52M/Transceiver.h +++ b/Transceiver52M/Transceiver.h @@ -95,6 +95,7 @@ private: int mSamplesPerSymbol; ///< number of samples per GSM symbol bool mOn; ///< flag to indicate that transceiver is powered on + bool mRunning; ///< flag to indicate control loop is running double mTxFreq; ///< the transmit frequency double mRxFreq; ///< the receive frequency int mPower; ///< the transmit power in dB @@ -134,6 +135,9 @@ public: /** start the Transceiver */ void start(); + /** shutdown (teardown threads) the Transceiver */ + void shutdown(); + /** attach the radioInterface receive FIFO */ void receiveFIFO(VectorFIFO *wFIFO) { mReceiveFIFO = wFIFO;} @@ -165,6 +169,12 @@ protected: void reset(); + /** return transceiver on/off status */ + bool on() { return mOn; } + + /** return control loop operational status */ + bool running() { return mRunning; } + /** set priority on current thread */ void setPriority() { mRadioInterface->setPriority(); } |