Boost logo

Boost Users :

Subject: Re: [Boost-users] Setting thread affinity on Linux using boost::thread
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-02-16 16:52:08


Hi,
----- Original Message -----
From: "Lennyk" <lennyk430_at_[hidden]>
To: <boost-users_at_[hidden]>
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 list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net