diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-04-25 10:17:23 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-04-25 10:17:23 -0400 |
commit | 566d8578955c0e94de17aea98de2f5f753d6b67d (patch) | |
tree | 4857d803124bdeeced746075a575b4402e005a5e /gnuradio-runtime/lib/thread/thread.cc | |
parent | d78d1ce2069ae20c86f9f301d89f303c2ae5942e (diff) | |
parent | 2db3dc73eb632bc853db70a41148e8f2cfecd3b0 (diff) |
Merge branch 'maint'
Diffstat (limited to 'gnuradio-runtime/lib/thread/thread.cc')
-rw-r--r-- | gnuradio-runtime/lib/thread/thread.cc | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/gnuradio-runtime/lib/thread/thread.cc b/gnuradio-runtime/lib/thread/thread.cc index 53eb23b2f0..8c59b6df74 100644 --- a/gnuradio-runtime/lib/thread/thread.cc +++ b/gnuradio-runtime/lib/thread/thread.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2012-2013 Free Software Foundation, Inc. + * Copyright 2012-2014 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -73,7 +73,7 @@ namespace gr { DWORD_PTR ret = SetThreadAffinityMask(thread, dword_mask); if(ret == 0) { std::stringstream s; - s << "thread_bind_to_processor failed with error: " + s << "thread_bind_to_processor failed with error: " << GetLastError() << std::endl; throw std::runtime_error(s.str()); } @@ -98,14 +98,14 @@ namespace gr { } } - int + int thread_priority(gr_thread_t thread) { // Not implemented on Windows return -1; } - - int + + int set_thread_priority(gr_thread_t thread, int priority) { // Not implemented on Windows @@ -200,18 +200,26 @@ namespace gr { // Not implemented on OSX } - int + int thread_priority(gr_thread_t thread) { - // Not implemented on OSX - return -1; + sched_param param; + int priority; + int policy; + int ret; + ret = pthread_getschedparam (thread, &policy, ¶m); + priority = param.sched_priority; + return (ret==0)?priority:ret; } - - int + + int set_thread_priority(gr_thread_t thread, int priority) { - // Not implemented on OSX - return -1; + int policy; + struct sched_param param; + pthread_getschedparam (thread, &policy, ¶m); + param.sched_priority = priority; + return pthread_setschedparam(thread, policy, ¶m); } void @@ -305,7 +313,7 @@ namespace gr { } } - int + int thread_priority(gr_thread_t thread) { sched_param param; @@ -316,8 +324,8 @@ namespace gr { priority = param.sched_priority; return (ret==0)?priority:ret; } - - int + + int set_thread_priority(gr_thread_t thread, int priority) { int policy; |