Boost logo

Boost Users :

Subject: Re: [Boost-users] [thread] set thread affinity
From: Lars Viklund (zao_at_[hidden])
Date: 2011-07-08 02:26:42

On Thu, Jul 07, 2011 at 07:16:04PM -0600, James C. Sutherland wrote:
> Is it possible to set thread affinity through boost::thread? I suspect that
> I am losing performance in my application because the OS is migrating
> threads and causing cache thrashing...

The question arose on the IRC channel a week ago or so.

There is no such functionality in Boost.Thread, you need to use native
functions like the GNU pthread_setaffinity_np (non-standard) or
the Windows SetThreadAffinityMask. On Linux, sched_setaffinity may or
may not work, depending on what you and your OS considers a "PID".

Of course, you could always write a patch targetting the platforms where
such functionality exists and suggest it for inclusion.

Lars Viklund | zao_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at