[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/09: runtime: enable thread priority, sam
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/09: runtime: enable thread priority, same as with Linux; fix header comments to this effect |
Date: |
Fri, 25 Apr 2014 16:44:34 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch maint
in repository gnuradio.
commit e4ce0b18808c65ea52602a28207fe9d5c0292ffe
Author: Michael Dickens <address@hidden>
Date: Thu Apr 24 10:08:39 2014 -0400
runtime: enable thread priority, same as with Linux; fix header comments to
this effect
---
gnuradio-runtime/include/gnuradio/thread/thread.h | 8 ++------
gnuradio-runtime/lib/thread/thread.cc | 16 ++++++++++++----
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/gnuradio-runtime/include/gnuradio/thread/thread.h
b/gnuradio-runtime/include/gnuradio/thread/thread.h
index a0c9e4f..5149e21 100644
--- a/gnuradio-runtime/include/gnuradio/thread/thread.h
+++ b/gnuradio-runtime/include/gnuradio/thread/thread.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009-2013 Free Software Foundation, Inc.
+ * Copyright 2009-2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -139,14 +139,10 @@ namespace gr {
GR_RUNTIME_API void thread_unbind(gr_thread_t thread);
/*! \brief get current thread priority for a given thread ID
- *
- * Note: this does not work on OSX
*/
GR_RUNTIME_API int thread_priority(gr_thread_t thread);
- /*! \brief get current thread priority for a given thread ID
- *
- * Note: this does not work on OSX
+ /*! \brief set current thread priority for a given thread ID
*/
GR_RUNTIME_API int set_thread_priority(gr_thread_t thread, int priority);
diff --git a/gnuradio-runtime/lib/thread/thread.cc
b/gnuradio-runtime/lib/thread/thread.cc
index 8d1ef76..1b3ebe5 100644
--- a/gnuradio-runtime/lib/thread/thread.cc
+++ b/gnuradio-runtime/lib/thread/thread.cc
@@ -167,15 +167,23 @@ namespace gr {
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
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);
}
} /* namespace thread */
- [Commit-gnuradio] [gnuradio] branch maint updated (1567cbc -> aa4a33d), git, 2014/04/25
- [Commit-gnuradio] [gnuradio] 07/09: blocks: fixed documentation for what the max_XX block does., git, 2014/04/25
- [Commit-gnuradio] [gnuradio] 04/09: runtime: enable thread priority, same as with Linux; fix header comments to this effect,
git <=
- [Commit-gnuradio] [gnuradio] 05/09: channels: fixing a minor bug in the flag_fader model., git, 2014/04/25
- [Commit-gnuradio] [gnuradio] 09/09: Merge branch 'maint' of git.gnuradio.org:gnuradio into maint, git, 2014/04/25
- [Commit-gnuradio] [gnuradio] 03/09: audio: osx: rename d_buffer_sample_count -> d_buffer_size_samples; truth in naming!, git, 2014/04/25
- [Commit-gnuradio] [gnuradio] 02/09: whitespace only, git, 2014/04/25
- [Commit-gnuradio] [gnuradio] 01/09: audio: osx audio fixes, git, 2014/04/25
- [Commit-gnuradio] [gnuradio] 08/09: cmake: fixes expansion of ${pyexe_native} for cross builds with the use of VERBATIM., git, 2014/04/25
- [Commit-gnuradio] [gnuradio] 06/09: docs: fixed typo with logger docs., git, 2014/04/25