diff options
-rw-r--r-- | src/DabMod.cpp | 4 | ||||
-rw-r--r-- | src/FIRFilter.cpp | 3 | ||||
-rw-r--r-- | src/OutputUHD.cpp | 6 | ||||
-rw-r--r-- | src/Utils.cpp | 9 | ||||
-rw-r--r-- | src/Utils.h | 2 |
5 files changed, 24 insertions, 0 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp index e0e7f8e..b5e3568 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -751,6 +751,10 @@ int launch_modulator(int argc, char* argv[]) } #endif + // Set thread priority to realtime + if (int r = set_realtime_prio(1)) { + etiLog.level(error) << "Could not set priority for modulator:" << r; + } while (run_again) { Flowgraph flowgraph; diff --git a/src/FIRFilter.cpp b/src/FIRFilter.cpp index e217288..ebd4518 100644 --- a/src/FIRFilter.cpp +++ b/src/FIRFilter.cpp @@ -29,6 +29,7 @@ #include "FIRFilter.h" #include "PcDebug.h" +#include "Utils.h" #include <stdio.h> #include <stdexcept> @@ -55,6 +56,8 @@ void FIRFilterWorker::process(struct FIRFilterWorkerData *fwd) struct timespec time_start; struct timespec time_end; + set_realtime_prio(1); + // This thread creates the dataOut buffer, and deletes // the incoming buffer diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index a49b659..dff0fd2 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -45,6 +45,7 @@ #include <time.h> #include <errno.h> #include <unistd.h> +#include <pthread.h> using namespace std; @@ -595,6 +596,11 @@ void OutputUHD::check_gps() void UHDWorker::process_errhandler() { + // Set thread priority to realtime + if (int ret = set_realtime_prio(1)) { + etiLog.level(error) << "Could not set priority for UHD worker:" << ret; + } + process(); uwd->running = false; etiLog.level(warn) << "UHD worker terminated"; diff --git a/src/Utils.cpp b/src/Utils.cpp index 4805374..ab1866c 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -114,4 +114,13 @@ void printVersion(void) } +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; +} diff --git a/src/Utils.h b/src/Utils.h index f023646..7f65fa3 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -57,6 +57,8 @@ inline long timespecdiff_us(struct timespec& oldTime, struct timespec& time) return tv_sec * 1000 + tv_nsec / 1000; } +// Set SCHED_RR with priority prio (0=lowest) +int set_realtime_prio(int prio); #endif |