Transceiver52M: Set variable thread priority levels

The transceiver and underlying device drivers are threaded. use
the following priority levels.

0.50 - UHD driver internal threads
0.45 - Receive device drive thread
0.44 - Transmit device drive thread
0.43 - UHD asynchronous update thread (error reporting)
0.42 - Receive burst processing thread(s)

Signed-off-by: Thomas Tsou <tom@tsou.cc>
This commit is contained in:
Thomas Tsou 2013-11-08 12:50:03 -05:00
parent 7e4e536b1b
commit 7553aa973f
6 changed files with 14 additions and 10 deletions

View File

@ -800,6 +800,8 @@ void *RxUpperLoopAdapter(TransceiverChannel *chan)
delete chan;
trx->setPriority(0.42);
while (1) {
trx->driveReceiveFIFO(num);
pthread_testcancel();
@ -809,7 +811,7 @@ void *RxUpperLoopAdapter(TransceiverChannel *chan)
void *RxLowerLoopAdapter(Transceiver *transceiver)
{
transceiver->setPriority();
transceiver->setPriority(0.45);
while (1) {
transceiver->driveReceiveRadio();
@ -820,6 +822,8 @@ void *RxLowerLoopAdapter(Transceiver *transceiver)
void *TxLowerLoopAdapter(Transceiver *transceiver)
{
transceiver->setPriority(0.44);
while (1) {
transceiver->driveTxFIFO();
pthread_testcancel();

View File

@ -235,7 +235,7 @@ protected:
void reset();
/** set priority on current thread */
void setPriority() { mRadioInterface->setPriority(); }
void setPriority(float prio = 0.5) { mRadioInterface->setPriority(prio); }
};

View File

@ -218,7 +218,7 @@ public:
bool start();
bool stop();
void restart(uhd::time_spec_t ts);
void setPriority();
void setPriority(float prio);
enum TxWindowType getWindowType() { return tx_window; }
int readSamples(std::vector<short *> &bufs, int len, bool *overrun,
@ -308,6 +308,8 @@ private:
void *async_event_loop(uhd_device *dev)
{
dev->setPriority(0.43);
while (1) {
dev->recv_async_msg();
pthread_testcancel();
@ -673,8 +675,6 @@ bool uhd_device::start()
return false;
}
setPriority();
// Register msg handler
uhd::msg::register_handler(&uhd_msg_handler);
@ -703,9 +703,9 @@ bool uhd_device::stop()
return true;
}
void uhd_device::setPriority()
void uhd_device::setPriority(float prio)
{
uhd::set_thread_priority_safe();
uhd::set_thread_priority_safe(prio);
return;
}

View File

@ -108,7 +108,7 @@ private:
bool stop();
/** Set priority not supported */
void setPriority() { }
void setPriority(float prio = 0.5) { }
enum TxWindowType getWindowType() { return TX_WINDOW_USRP1; }

View File

@ -52,7 +52,7 @@ class RadioDevice {
virtual enum TxWindowType getWindowType()=0;
/** Enable thread priority */
virtual void setPriority()=0;
virtual void setPriority(float prio = 0.5) = 0;
/**
Read samples from the radio.

View File

@ -133,7 +133,7 @@ public:
double fullScaleOutputValue();
/** set thread priority on current thread */
void setPriority() { mRadio->setPriority(); }
void setPriority(float prio = 0.5) { mRadio->setPriority(prio); }
/** get transport window type of attached device */
enum RadioDevice::TxWindowType getWindowType() { return mRadio->getWindowType(); }