Setting thread affinity on Linux using boost::thread
Hi, I'm running on Linux and I would like to set a specific thread affinity to each thread I create (i.e. setting each thread to run on a different core/CPU). How can this be done using the boost::thread library? Thanks! Lenny.
hi all
just out of convenience i try to create a class which helps me manage my
resources usage
it only gets function arguments and a boost::function on construction
and this function is called with the given arguments during destruction
the constructor currently looks like this
template
jeti wrote:
i try to create a class which helps me manage my resources usage it only gets function arguments and a boost::function on construction and this function is called with the given arguments during destruction
the constructor currently looks like this template
Callback(boost::function ,R arg1); so this would be great template
Callback(boost::function ,R arg1,....); which i dont know how to achive or if this can easily be done using current c++ standard any alternative/creative suggestions on this would be great
? To me it looks as if you're home free. The following builds and runs
and produces the result I expect:
#include <iostream>
#include
jeti wrote:
i try to create a class which helps me manage my resources usage it only gets function arguments and a boost::function on construction and this function is called with the given arguments during destruction
I should also have mentioned the recently-approved scope_exit library: http://svn.boost.org/svn/boost/trunk/libs/scope_exit/doc/html/index.html
Nat Goodspeed wrote:
jeti wrote:
i try to create a class which helps me manage my resources usage it only gets function arguments and a boost::function on construction and this function is called with the given arguments during destruction
I should also have mentioned the recently-approved scope_exit library: http://svn.boost.org/svn/boost/trunk/libs/scope_exit/doc/html/index.html _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
you're right the example you provided is working and im using something similar now the problem i had that i tried to call a function with a wrong parameter type and since im using multi_index for this the compiler error message got a size that i didnt see the wood for the trees btw: nice library i will have a look on it thx for your help
Hi,
----- Original Message -----
From: "Lennyk"
Hi,
I'm running on Linux and I would like to set a specific thread affinity to each thread I create (i.e. setting each thread to run on a different core/CPU). How can this be done using the boost::thread library?
Oliver Kowalke, the author of the Boost.ThreadPool has posted a compressed file boost-bind_processor.v1.tar.gz in Boost Vault http://www.boostpro.com/vault/index.php?directory=Concurrent%20Programming&PHPSESSID=96307fee8086c06036af42fae790b449 This file contains functions which allows bind/unbind current thread to a processor boost::this_thread::bind_to_processor( unsigned int n); // thread gets bound to processor n boost::this_thread::bind_to_any_processor(); // thread can be scheduled to all available processors Both functions will throw boost::system_error. Processors are enumerated starting at 0. HTH, Vicente
vicente.botet wrote:
Hi, ----- Original Message ----- From: "Lennyk"
To: Sent: Sunday, February 15, 2009 6:14 PM Subject: [Boost-users] Setting thread affinity on Linux using boost::thread Hi,
I'm running on Linux and I would like to set a specific thread affinity to each thread I create (i.e. setting each thread to run on a different core/CPU). How can this be done using the boost::thread library?
Oliver Kowalke, the author of the Boost.ThreadPool has posted a compressed file boost-bind_processor.v1.tar.gz in Boost Vault http://www.boostpro.com/vault/index.php?directory=Concurrent%20Programming&PHPSESSID=96307fee8086c06036af42fae790b449
This file contains functions which allows bind/unbind current thread to a processor
boost::this_thread::bind_to_processor( unsigned int n); // thread gets bound to processor n
boost::this_thread::bind_to_any_processor(); // thread can be scheduled to all available processors
Both functions will throw boost::system_error. Processors are enumerated starting at 0.
HTH, Vicente
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Great! Thanks! Lenny
participants (4)
-
jeti
-
Lennyk
-
Nat Goodspeed
-
vicente.botet