summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/thread
diff options
context:
space:
mode:
authorTim O'Shea <tim.oshea753@gmail.com>2013-06-05 10:52:22 -0400
committerTim O'Shea <tim.oshea753@gmail.com>2013-06-05 14:20:37 -0400
commit2df6f769ce2cd026d92778ded780941ac3a0da0c (patch)
tree6ae067e8e75fdd65f97755690cd483fe592304ba /gnuradio-runtime/lib/thread
parent9c154832f1db9a7cc0a8ebe33e8798541335caf1 (diff)
runtime: adding thread priority methods to gr::block
Diffstat (limited to 'gnuradio-runtime/lib/thread')
-rw-r--r--gnuradio-runtime/lib/thread/thread.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/gnuradio-runtime/lib/thread/thread.cc b/gnuradio-runtime/lib/thread/thread.cc
index 1727dc6621..d79d1a0129 100644
--- a/gnuradio-runtime/lib/thread/thread.cc
+++ b/gnuradio-runtime/lib/thread/thread.cc
@@ -97,6 +97,20 @@ namespace gr {
}
}
+ int
+ thread_priority(gr_thread_t thread)
+ {
+ // Not implemented on Windows
+ return -1;
+ }
+
+ int
+ set_thread_priority(gr_thread_t thread, int priority)
+ {
+ // Not implemented on Windows
+ return -1;
+ }
+
} /* namespace thread */
} /* namespace gr */
@@ -148,6 +162,20 @@ namespace gr {
// Not implemented on OSX
}
+ int
+ thread_priority(gr_thread_t thread)
+ {
+ // Not implemented on OSX
+ return -1;
+ }
+
+ int
+ set_thread_priority(gr_thread_t thread, int priority)
+ {
+ // Not implemented on OSX
+ return -1;
+ }
+
} /* namespace thread */
} /* namespace gr */
@@ -232,6 +260,28 @@ namespace gr {
}
}
+ int
+ thread_priority(gr_thread_t thread)
+ {
+ sched_param param;
+ int priority;
+ int policy;
+ int ret;
+ ret = pthread_getschedparam (thread, &policy, &param);
+ priority = param.sched_priority;
+ return (ret==0)?priority:ret;
+ }
+
+ int
+ set_thread_priority(gr_thread_t thread, int priority)
+ {
+ int policy;
+ struct sched_param param;
+ pthread_getschedparam (thread, &policy, &param);
+ param.sched_priority = priority;
+ return pthread_setschedparam(thread, policy, &param);
+ }
+
} /* namespace thread */
} /* namespace gr */