summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-06-17 11:26:57 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-06-17 11:26:57 +0200
commite48df9cb5ec9e48cd836ec227127f42c5cc99aa1 (patch)
treefc54e01b5397c8c4017170f685e34b2270e2f880 /src
parentbab9d654f028a214e6f3abe8ade1c1da002d25ff (diff)
downloaddabmod-e48df9cb5ec9e48cd836ec227127f42c5cc99aa1.tar.gz
dabmod-e48df9cb5ec9e48cd836ec227127f42c5cc99aa1.tar.bz2
dabmod-e48df9cb5ec9e48cd836ec227127f42c5cc99aa1.zip
Set SCHED_RR prio for all data processing threads
This includes Modulator, FIR Filter and UHD worker
Diffstat (limited to 'src')
-rw-r--r--src/DabMod.cpp4
-rw-r--r--src/FIRFilter.cpp3
-rw-r--r--src/OutputUHD.cpp6
-rw-r--r--src/Utils.cpp9
-rw-r--r--src/Utils.h2
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