diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-02-04 22:19:46 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-02-04 22:19:46 +0100 |
commit | f907c18d8efb14c1f2138ef7699cb7b5b86200b8 (patch) | |
tree | 0b5bb3782f4f950768e36ba9bfee278d4c314867 | |
parent | 8ecda350fbde0d544ba284f0441859e2a52b4ce3 (diff) | |
download | odr-dpd-f907c18d8efb14c1f2138ef7699cb7b5b86200b8.tar.gz odr-dpd-f907c18d8efb14c1f2138ef7699cb7b5b86200b8.tar.bz2 odr-dpd-f907c18d8efb14c1f2138ef7699cb7b5b86200b8.zip |
Set realtime priority
-rw-r--r-- | OutputUHD.cpp | 2 | ||||
-rw-r--r-- | main.cpp | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/OutputUHD.cpp b/OutputUHD.cpp index 255f63f..d37879b 100644 --- a/OutputUHD.cpp +++ b/OutputUHD.cpp @@ -49,7 +49,9 @@ OutputUHD::OutputUHD(double txgain, double rxgain, double samplerate) : m_usrp = uhd::usrp::multi_usrp::make(device); m_usrp->set_tx_rate(m_samplerate); + MDEBUG("OutputUHD:Actual TX rate: %f\n", m_usrp->get_tx_rate()); m_usrp->set_rx_rate(m_samplerate); + MDEBUG("OutputUHD:Actual RX rate: %f\n", m_usrp->get_rx_rate()); m_usrp->set_tx_freq(234.208e6); double set_tx_frequency = m_usrp->get_tx_freq(); @@ -42,6 +42,17 @@ void sig_int_handler(int) { running = false; } +static int set_realtime_prio(int prio) +{ + // Set thread priority to realtime + const int policy = SCHED_RR; + sched_param sp; + sp.sched_priority = sched_get_priority_min(policy) + prio; + int ret = pthread_setschedparam(pthread_self(), policy, &sp); + return ret; +} + + size_t read_samples_from_file(FILE* fd, std::vector<complexf>& samples, size_t count) { if (samples.size() < count) { @@ -180,7 +191,6 @@ void analyse_correlation() } } - int main(int argc, char **argv) { double txgain = 0; @@ -207,6 +217,8 @@ int main(int argc, char **argv) return -1; } + set_realtime_prio(1); + std::string uri = argv[1]; zmq::context_t ctx; |