aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-06-05 09:10:52 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-06-05 09:10:52 +0200
commitc9ea7fb88809d935f3eaeee108415ff5abd17ead (patch)
treec5dbadc0c2a391830b32d965a7f9e225bd70d684 /src
parente3cc55d32281be5dd7b7017d6dfed42be24d3cda (diff)
downloaddabmod-c9ea7fb88809d935f3eaeee108415ff5abd17ead.tar.gz
dabmod-c9ea7fb88809d935f3eaeee108415ff5abd17ead.tar.bz2
dabmod-c9ea7fb88809d935f3eaeee108415ff5abd17ead.zip
Set priorities for modulator and UHD threads
Diffstat (limited to 'src')
-rw-r--r--src/DabMod.cpp9
-rw-r--r--src/OutputUHD.cpp14
2 files changed, 19 insertions, 4 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index 2fe8d53..57f03b9 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -768,6 +768,15 @@ int launch_modulator(int argc, char* argv[])
}
#endif
+ // Set thread priority to realtime
+ const int policy = SCHED_RR;
+ sched_param sp;
+ sp.sched_priority = sched_get_priority_min(policy);
+ int thread_prio_ret = pthread_setschedparam(pthread_self(), policy, &sp);
+ if (thread_prio_ret != 0) {
+ etiLog.level(error) << "Could not set priority for Modulator thread:" << thread_prio_ret;
+ }
+
while (run_again) {
Flowgraph flowgraph;
diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp
index 28df515..ad31be7 100644
--- a/src/OutputUHD.cpp
+++ b/src/OutputUHD.cpp
@@ -104,12 +104,8 @@ OutputUHD::OutputUHD(
RC_ADD_PARAMETER(muting, "Mute the output by stopping the transmitter");
RC_ADD_PARAMETER(staticdelay, "Set static delay (uS) between 0 and 96000");
- // TODO: find out how to use boost::bind to give the logger to the
- // uhd_msg_handler
uhd::msg::register_handler(uhd_msg_handler);
- uhd::set_thread_priority_safe();
-
//create a usrp device
MDEBUG("OutputUHD:Creating the usrp device with: %s...\n",
device.str().c_str());
@@ -477,6 +473,16 @@ void UHDWorker::process()
// Transmit timeout
const double timeout = 20.0;
+ // Set thread priority to realtime
+ const int policy = SCHED_RR;
+ sched_param sp;
+ sp.sched_priority = sched_get_priority_min(policy);
+ int ret = pthread_setschedparam(pthread_self(), policy, &sp);
+ if (ret != 0) {
+ etiLog.level(error) << "Could not set priority for UHD thread:" << ret;
+ }
+
+
#if FAKE_UHD == 0
uhd::stream_args_t stream_args("fc32"); //complex floats
uhd::tx_streamer::sptr myTxStream = uwd->myUsrp->get_tx_stream(stream_args);