Thread prioritization on OSX

Hello all, according to this: http://www.boost.org/doc/libs/1_57_0/doc/html/thread/thread_management.html #thread.thread_management.tutorial.attributes I tried to change the thread priority to SCHED_RR on OS X via: boost::thread::attributes attrs; pthread_attr_setschedpolicy(attrs.get_native_handle(), SCHED_RR); sendThread = boost::thread(attrs,&sender::sendItThreadFunction,this); In that context I noticed that get_native_handle is not known so I used attr.native_handle(), which compiled ok but finally threw an error here: /boost/boost/bind/bind.hpp:313:9: Type 'boost::thread_attributes' does not provide a call operator I am still using boost 1.45 and wonder if this is the actual problem or if something else is wrong. Any help appreciated, thanks Alex Am 20.11.14 10:53 schrieb "Ben Pope" unter <benpope81@gmail.com>:
On Thursday, November 20, 2014 05:27 PM, Alexander Carôt wrote:
Hello all,
is it correct that boost does not offer thread prioritization ?
There's nothing directly on the interface.
I am dealing with an application with a number of threads, which all depend on the realtime-scheduled sound card callback thread.
These threads must have the same realtime scheduling priority.
Is there a way to achieve this ?
Basically there's a platform specific back door: native_handle.
http://www.boost.org/doc/libs/1_57_0/doc/html/thread/thread_management.htm l#thread.thread_management.tutorial.attributes
Ben
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Le 06/12/14 22:10, Alexander Carôt a écrit :
Hello all,
according to this:
http://www.boost.org/doc/libs/1_57_0/doc/html/thread/thread_management.html #thread.thread_management.tutorial.attributes
I tried to change the thread priority to SCHED_RR on OS X via:
boost::thread::attributes attrs; pthread_attr_setschedpolicy(attrs.get_native_handle(), SCHED_RR); sendThread = boost::thread(attrs,&sender::sendItThreadFunction,this);
In that context I noticed that get_native_handle is not known so I used attr.native_handle(), which compiled ok but finally threw an error here: Sorry, the tutorial is wrong. It should be native_handle()
/boost/boost/bind/bind.hpp:313:9: Type 'boost::thread_attributes' does not provide a call operator
Please, could you post the source code and more context of the compile error?
I am still using boost 1.45 and wonder if this is the actual problem or if something else is wrong.
I will check the code of this version. Best, Vicente

Le 07/12/14 00:35, Vicente J. Botet Escriba a écrit :
Le 06/12/14 22:10, Alexander Carôt a écrit :
Hello all,
according to this:
http://www.boost.org/doc/libs/1_57_0/doc/html/thread/thread_management.html
#thread.thread_management.tutorial.attributes
I tried to change the thread priority to SCHED_RR on OS X via:
boost::thread::attributes attrs; pthread_attr_setschedpolicy(attrs.get_native_handle(), SCHED_RR); sendThread = boost::thread(attrs,&sender::sendItThreadFunction,this);
In that context I noticed that get_native_handle is not known so I used attr.native_handle(), which compiled ok but finally threw an error here: Sorry, the tutorial is wrong. It should be native_handle()
/boost/boost/bind/bind.hpp:313:9: Type 'boost::thread_attributes' does not provide a call operator
Please, could you post the source code and more context of the compile error?
I am still using boost 1.45 and wonder if this is the actual problem or if something else is wrong.
I will check the code of this version.
Done. Thread attributes were included in 1.50 :( Version 3.0.0 - boost 1.50 New Features: * #2741 Proposal to manage portable and non portable thread attributes. Best, Vicente P.S. Please, look at the documentation of the version you are using.

Hello Vincente, thanks a lot for your quick response !
Sorry, the tutorial is wrong. It should be native_handle()
I have one more: On the same document the Thread attributes chapter starts with the example attrs.set_size(4096*10); Her it has to be set_stack_size as in the example below. Maybe you can find some time to fix it.
Done. Thread attributes were included in 1.50 :( P.S. Please, look at the documentation of the version you are using.
Yes sure ! I am not a bloody boost-beginner but still not very experience with it. So, I just needed confirmation that my guess is correct. My project is rather complex and deals with a 3rd-party-component for which I need to update boost now. Hope it¹s gonna work out I might get back on this. Thanks again, best Alex Von: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr> Antworten an: <boost-users@lists.boost.org> Datum: Sonntag, 7. Dezember 2014 00:40 An: <boost-users@lists.boost.org> Betreff: Re: [Boost-users] Thread prioritization on OSX
Le 07/12/14 00:35, Vicente J. Botet Escriba a écrit :
Le 06/12/14 22:10, Alexander Carôt a écrit :
Hello all,
according to this:
http://www.boost.org/doc/libs/1_57_0/doc/html/thread/thread_management.html #thread.thread_management.tutorial.attributes
I tried to change the thread priority to SCHED_RR on OS X via:
boost::thread::attributes attrs; pthread_attr_setschedpolicy(attrs.get_native_handle(), SCHED_RR); sendThread = boost::thread(attrs,&sender::sendItThreadFunction,this);
In that context I noticed that get_native_handle is not known so I used attr.native_handle(), which compiled ok but finally threw an error here:
Sorry, the tutorial is wrong. It should be native_handle()
/boost/boost/bind/bind.hpp:313:9: Type 'boost::thread_attributes' does not provide a call operator
Please, could you post the source code and more context of the compile error?
I am still using boost 1.45 and wonder if this is the actual problem or if something else is wrong.
I will check the code of this version.
Done. Thread attributes were included in 1.50 :(
Version 3.0.0 - boost 1.50 New Features:
* #2741 Proposal to manage portable and non portable thread attributes.
Best, Vicente
P.S. Please, look at the documentation of the version you are using.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Le 07/12/14 18:04, Alexander Carôt a écrit :
Hello Vincente,
thanks a lot for your quick response !
Sorry, the tutorial is wrong. It should be native_handle()
I have one more: On the same document the Thread attributes chapter starts with the example attrs.set_size(4096*10); Her it has to be set_stack_size as in the example below. Maybe you can find some time to fix it.
Just done (https://github.com/boostorg/thread/commit/063b59e511a2bfd323b0fcdd06c3499473...). Thanks for reporting, Vicente

Hi Vincente, I successfully updated to the latest boost in my project but (for some reason) I still encounter the same problem. My thread is created thus: boost::thread::attributes attrs; pthread_attr_setschedpolicy(attrs.native_handle(), SCHED_RR); sendThread = boost::thread(attrs,&sender::sendItThreadFunction,this); but upon compilation time I get the following error in bind.hpp: template<class F, class A> void operator()(type<void>, F & f, A & a, int){ unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); /// Error: Type 'boost::thread_attributes does not provide a call operator } I compared this call with the one from the old bind.hpp (of version 1.45) and noticed that both are equal. Now I wonder if I am still messing it up or if something else is probably wrong. Please let me know. Thanks, best Alex Von: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr> Antworten an: <boost-users@lists.boost.org> Datum: Sonntag, 7. Dezember 2014 19:05 An: <boost-users@lists.boost.org> Betreff: Re: [Boost-users] Thread prioritization on OSX
Le 07/12/14 18:04, Alexander Carôt a écrit :
Hello Vincente,
thanks a lot for your quick response !
Sorry, the tutorial is wrong. It should be native_handle()
I have one more: On the same document the Thread attributes chapter starts with the example
attrs.set_size(4096*10);
Her it has to be set_stack_size as in the example below. Maybe you can find some time to fix it.
Just done (https://github.com/boostorg/thread/commit/063b59e511a2bfd323b0fcdd06c3499473... a18db).
Thanks for reporting, Vicente
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Le 12/12/14 10:43, Alexander Carôt a écrit :
Hi Vincente,
I successfully updated to the latest boost in my project but (for some reason) I still encounter the same problem.
My thread is created thus:
boost::thread::attributes attrs;
pthread_attr_setschedpolicy(attrs.native_handle(), SCHED_RR);
sendThread = boost::thread(attrs,&sender::sendItThreadFunction,this);
but upon compilation time I get the following error in bind.hpp:
template<class F, class A> void operator()(type<void>, F & f, A & a, int){
unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); /// Error: Type 'boost::thread_attributes‘ does not provide a call operator
}
I compared this call with the one from the old bind.hpp (of version 1.45) and noticed that both are equal.
Now I wonder if I am still messing it up or if something else is probably wrong.
I suspect that you are using the old version. Please, could you see the result of the pre-processor (option -E with gcc/clang)? Vicente

Now I wonder if I am still messing it up or if something else is probably wrong.
I suspect that you are using the old version. Please, could you see the result of the pre-processor (option -E with gcc/clang)?
I typically check this via including #include <boost/version.hpp> and cout the BOOST_VERSION. It tells me it is version 1.56 and in fact it cannot use any other version because I do not have a system installation. Is there anything else I can do in order to approach the error ? Thanks Alex

/boost/boost/bind/bind.hpp:313:9: Type 'boost::thread_attributes' does not provide a call operator
I am still using boost 1.45 and wonder if this is the actual problem or if something else is wrong.
Also I just figured that someone forward a wrong version info. After I checked it myself I realized that (before the update) I was using 1.50 (and not 1.45), which makes me think that my thread-prioritization-problem is not a version issue. Best Alex

Le 13/12/14 01:42, Alexander Carôt a écrit :
/boost/boost/bind/bind.hpp:313:9: Type 'boost::thread_attributes' does not provide a call operator
I am still using boost 1.45 and wonder if this is the actual problem or if something else is wrong. Also I just figured that someone forward a wrong version info. After I checked it myself I realized that (before the update) I was using 1.50 (and not 1.45), which makes me think that my thread-prioritization-problem is not a version issue.
Any way, could you send me the result of the preprocessor? Best, Vicente
participants (2)
-
Alexander Carôt
-
Vicente J. Botet Escriba